{"id":642,"date":"2018-10-02T18:15:49","date_gmt":"2018-10-02T21:45:49","guid":{"rendered":"http:\/\/blog.pelleys.com\/?p=642"},"modified":"2018-10-02T18:18:29","modified_gmt":"2018-10-02T21:48:29","slug":"lets-encrypt-nginx-and-certbot-a-short-story","status":"publish","type":"post","link":"https:\/\/blog.pelleys.com\/?p=642","title":{"rendered":"Let&#8217;s Encrypt, nginx and certbot &#8211; a short story"},"content":{"rendered":"\r\n<p>Well, the duration &#8211; for me -was not short. It was about two weeks of living in Google.\u00a0<\/p>\r\n\r\n\r\n\r\n<p>Here&#8217;s the setup: I have a couple of servers in my DMZ that I want share out. Some places do not let web traffic out on non-standard ports (i.e., TCP 80 and 443) so I wanted to share out the two servers on my single IP address. As I like to try different things, I decided on using nginx instead of Apache HTTPD. (I like both &#8211; some things in nginx seem a little more organized&#8230;) Setting up nginx as a reverse proxy &#8211; no problem at all!\u00a0<\/p>\r\n\r\n\r\n\r\n<p>Of course, I am &#8211; within reason, see my post on <a href=\"https:\/\/blog.pelleys.com\/?p=632\">HTTPS everywhere<\/a> &#8211; in agreement with encryption. Thus, Let&#8217;s Encrypt was next on the list. With my other static web servers (using Apache HTTPD) no problem; good old certbot is brain dead easy.<\/p>\r\n\r\n\r\n\r\n<p>Not with a reverse proxy (I also tried Apache HTTPD without luck) &#8211; at least for me. Repeated 404 errors&#8230; &#8220;not authorized&#8221;&#8230; Arrrgggg&#8230; Google university was of no help &#8211; all the same basic instructions. Same error.\u00a0<\/p>\r\n\r\n\r\n\r\n<p>Until&#8230;\u00a0<\/p>\r\n\r\n\r\n\r\n<p>I found <a href=\"https:\/\/serverfault.com\/questions\/750902\/how-to-use-lets-encrypt-dns-challenge-validation\">this<\/a> post on StackExchange by\u00a0<a href=\"https:\/\/serverfault.com\/users\/383297\/ph4r05\">ph4r05<\/a>. Basically, I had to use a\u00a0manual verification with the manual plugin. This meant adding a TXT record to my DNS server.\u00a0<\/p>\r\n\r\n\r\n\r\n<p>To do this:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>certbot -d YOUR_FQDN_SERVER_NAME --manual --preferred-challenges dns certonly<\/code><\/pre>\r\n\r\n\r\n\r\n<p>This will give the response:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>Please deploy a DNS TXT record under the name\r\n_acme-challenge.YOUR_FQDN_SERVER_NAME with the following value:\r\n\r\n667drNmQL3vX6bu8YZlgy0wKNBlCny8yrjF1lSaUndc\r\n\r\nOnce this is deployed,\r\nPress ENTER to continue<\/code><\/pre>\r\n\r\n\r\n\r\n<p>Of course, the value will change for you (and it will change each time you do a manual validation). Once you get that key you will need to go into your (publicly accessible!) DNS server with a TXT record of:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">_acme-challenge.YOUR_FQDN_SERVER_NAME TXT\u00a0667drNmQL3vX6bu8YZlgy0wKNBlCny8yrjF1lSaUndc<\/pre>\r\n\r\n\r\n\r\n<p>(or however your DNS server enter it).<\/p>\r\n\r\n\r\n\r\n<p>You then have to\u00a0<em>wait<\/em> until Google&#8217;s name servers (8.8.8.8 or 8.8.4.4) updates. This took under 5 minutes for me. Once that is done (you can check with the linux dig command for propagation) hit ENTER. You will then have to put in your nginx site config the paths to the Let&#8217;s Encrypt certificates;e.g.,:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">\/etc\/letsencrypt\/live\/YOUR_SITE_NAME\/fullchain.pem\/<br \/>\/etc\/letsencrypt\/live\/YOUR_SITE_NAME\/pivkey.pem<\/pre>\r\n\r\n\r\n\r\n<p>Restart nginx &#8211; and Bob&#8217;s your uncle.<\/p>\r\n\r\n\r\n\r\n<p>Hopefully, someone else will find this post and it will save some time.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Well, the duration &#8211; for me -was not short. It was about two weeks of living in Google.\u00a0 Here&#8217;s the setup: I have a couple of servers in my DMZ that I want share out. Some places do not let &hellip; <a href=\"https:\/\/blog.pelleys.com\/?p=642\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-642","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=\/wp\/v2\/posts\/642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=642"}],"version-history":[{"count":0,"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pelleys.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}