{"id":5222,"date":"2026-04-10T21:15:26","date_gmt":"2026-04-10T12:15:26","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=5222"},"modified":"2026-04-10T22:22:59","modified_gmt":"2026-04-10T13:22:59","slug":"webserver-httplib-https-lets2-macos-linux","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2026\/04\/10\/webserver-httplib-https-lets2-macos-linux\/","title":{"rendered":"[Webserver]httplib webserver+https(Let&#8217;s Encrypt)(2)(MacOS,Linux)"},"content":{"rendered":"\n<p>\ud83d\udc49\ud83c\udffb \ub9ac\ub205\uc2a4\uc11c\ubc84\uc5d0\uc11c \ud14c\uc2a4\ud2b8 \ud55c \ub0b4\uc6a9\uc785\ub2c8\ub2e4.<br>This is the content tested on a Linux server.<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb Let&#8217;s Encrypt\ub85c https\ub97c \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4.<br>This is how to implement HTTPS with Let&#8217;s Encrypt.<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ubc29\ud654\ubcbd\uc624\ud508 \/ Firewall open<\/p>\n\n\n\n<p>&#8212; \uc544\ub798\ub294 iptables \ubc29\ud654\ubcbd \uc624\ud508 \ud558\ub294 \ub0b4\uc6a9\uc785\ub2c8\ub2e4.<br>Below is the content for opening the iptables firewall.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT\n$ sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT\n$ sudo iptables -I INPUT -p tcp --dport 5080 -j ACCEPT\n\n# iptables-persistent\uc124\uce58\uc548\ud55c\uacbd\uc6b0\n$ sudo apt install iptables-persistent\n\n# \uc124\uc815 \ub0b4\uc6a9\uc800\uc7a5 \/ Save settings\n$ sudo netfilter-persistent save<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb openssl\uc774\uc124\uce58\ub418\uc5b4 \uc788\uc9c0 \uc54a\uc73c\uba74 \uc124\uce58\ud569\ub2c8\ub2e4.<br>If openssl is not installed, install it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install g++ libssl-dev openssl wget -y<\/code><\/pre>\n\n\n\n<p>\u2b50\ufe0f openssl\uc740 3.0\uc774\uc0c1\uc744 \uc0ac\uc6a9\ud574\uc57c\ud569\ub2c8\ub2e4.<br>You must use openssl 3.0 or higher.<\/p>\n\n\n\n<p>\u2b50\ufe0f openssl 3.x\uc774\uc0c1\uc744 \uc0ac\uc6a9\ud558\ub824\uba74 \uc6b0\ubd84\ud22c 22.04\ubc84\uc804\uc774\uc0c1\uc774\uc5b4\uc57c\ud569\ub2c8\ub2e4.<br>To use openssl 3.x or higher, you must be running Ubuntu version 22.04 or higher.<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb Let&#8217;s Encrypt\uc778\uc99d\uc11c \ubc1b\uae30 \/ Get Let&#8217;s Encrypt Certificate<\/p>\n\n\n\n<p>&#8212; \ub2e4\uc74c\uacfc \uac19\uc740 \ud654\uba74\uc774 \ubcf4\uc774\uba74 \uc131\uacf5\ud55c \uac83\uc785\ub2c8\ub2e4.<br>If you see the following screen, you have succeeded.<\/p>\n\n\n\n<p>&#8211;\ubc29\ud654\ubcbd\uc774\ub098 \ud3ec\ud2b8\uac00 \ub9c9\ud788\uba74 \uc778\uc99d\uc11c \ubc1c\uae09\uc774 \ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<br>If the firewall or ports are blocked, the certificate cannot be issued.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$ <strong>sudo certbot certonly --standalone -d host.domain.com<\/strong>\nSaving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\nRequesting a certificate for host.domain.com\n\nSuccessfully received certificate.\nCertificate is saved at: \/etc\/letsencrypt\/live\/host.domain.com\/fullchain.pem\nKey is saved at:         \/etc\/letsencrypt\/live\/host.domain.com\/privkey.pem\nThis certificate expires on 2028-10-01.\nThese files will be updated when the certificate renews.\nCertbot has set up a scheduled task to automatically renew this certificate in the background.\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nIf you like Certbot, please consider supporting our work by:\n * Donating to ISRG \/ Let's Encrypt:   https:\/\/letsencrypt.org\/donate\n * Donating to EFF:                    https:\/\/eff.org\/donate-le\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n$ <\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ud604\uc7ac \uc11c\ubc84 \ub514\ub809\ud1a0\ub9ac\ub85c  \uc778\uc99d\uc11c\ub97c \ubcf5\uc0ac\ud569\ub2c8\ub2e4.<br>Copy certificate to current server directory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo cp \/etc\/letsencrypt\/live\/host.domain.com\/fullchain.pem .\/\n$ sudo cp \/etc\/letsencrypt\/live\/host.domain.com\/privkey.pem .\/\n\n# \ub0b4 \uacc4\uc815\uc73c\ub85c \uc18c\uc720\uad8c \ubcc0\uacbd \/ Change ownership to my account\n$ sudo chown username:username *.pem  <\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ucf54\ub4dc\/Code<\/p>\n\n\n\n<p>\u2714\ufe0f \uae30\uc874\uc758 \uc11c\ubc84 \ucf54\ub4dc\uc5d0\uc11c \uc778\uc99d\uc11c \ubd80\ubd84\ub9cc \uc218\uc815\ud569\ub2c8\ub2e4.<br>Modify only the certificate part of the existing server code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define CPPHTTPLIB_OPENSSL_SUPPORT\n#include \"httplib.h\"\n#include &lt;iostream&gt;\n\nint main( ) {\n    \/\/ \uc778\uc99d\uc11c\uc640 \ud0a4 \ud30c\uc77c \uacbd\ub85c\ub97c \uc9c0\uc815\ud569\ub2c8\ub2e4.\n    \/\/ Specify the certificate and key file paths.\n    <strong>httplib::SSLServer svr(\".\/fullchain.pem\", \".\/privkey.pem\" );<\/strong>\n\n    if (!svr.is_valid()) {\n        std::cerr &lt;&lt; \"SSL \uc11c\ubc84 \uc124\uc815 \uc2e4\ud328 \/ SSL server setup failed!\" &lt;&lt; std::endl;\n        return 1;\n    }\n\n    svr.Get(\"\/\", &#91;](const httplib::Request&amp;, httplib::Response&amp; res ) {\n        res.set_content(\"&lt;h1&gt; \ud83d\udc49 Linux  HTTPS Server is Running! \ud83d\udcd3 &lt;\/h1&gt;\", \"text\/html; charset=utf-8\");\n    });\n\n    std::cout &lt;&lt; \"Server Listening: https:\/\/0.0.0.0:5080\" &lt;&lt; std::endl;\n    svr.listen(\"0.0.0.0\", 5080 );\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ucef4\ud30c\uc77c \/ Compiling<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>g++ -o server server.cpp -std=c++11 -pthread -lssl -lcrypto<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \uc11c\ubc84\uc2e4\ud589 \/ Run server<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/server<\/code><\/pre>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb \ube0c\ub77c\uc6b0\uc800\uc811\uc18d \/ Browser access<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"353\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https-1024x353.jpg\" alt=\"\" class=\"wp-image-5238\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https-1024x353.jpg 1024w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https-300x103.jpg 300w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https-768x264.jpg 768w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https-400x138.jpg 400w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https-800x275.jpg 800w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2026\/04\/https.jpg 1150w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Screenshot<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udc49\ud83c\udffb \ub9ac\ub205\uc2a4\uc11c\ubc84\uc5d0\uc11c \ud14c\uc2a4\ud2b8 \ud55c \ub0b4\uc6a9\uc785\ub2c8\ub2e4.This is the content tested on a Linux server. \ud83d\udc49\ud83c\udffb Let&#8217;s Encrypt\ub85c https\ub97c \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4.This is how to implement HTTPS with Let&#8217;s Encrypt. \ud83d\udc49\ud83c\udffb \ubc29\ud654\ubcbd\uc624\ud508 \/ Firewall open &#8212; \uc544\ub798\ub294 iptables \ubc29\ud654\ubcbd \uc624\ud508 \ud558\ub294 \ub0b4\uc6a9\uc785\ub2c8\ub2e4.Below is the content for opening the iptables firewall. \ud83d\udc49\ud83c\udffb openssl\uc774\uc124\uce58\ub418\uc5b4 \uc788\uc9c0 \uc54a\uc73c\uba74 \uc124\uce58\ud569\ub2c8\ub2e4.If openssl is not [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,1],"tags":[],"class_list":["post-5222","post","type-post","status-publish","format-standard","hentry","category-cpp","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=5222"}],"version-history":[{"count":22,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5222\/revisions"}],"predecessor-version":[{"id":5247,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5222\/revisions\/5247"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=5222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=5222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=5222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}