{"id":892,"date":"2021-02-15T04:56:54","date_gmt":"2021-02-15T04:56:54","guid":{"rendered":"https:\/\/www.velaninfo.com\/rs\/?post_type=techtips&#038;p=892"},"modified":"2021-02-16T12:56:40","modified_gmt":"2021-02-16T12:56:40","slug":"how-to-secure-nginx-with-lets-encrypt-on-ubuntu","status":"publish","type":"techtips","link":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/","title":{"rendered":"How to Secure Nginx with Let&#8217;s Encrypt on Ubuntu?"},"content":{"rendered":"<p><strong>How to Secure Nginx with Let&#8217;s Encrypt on Ubuntu?<\/strong><\/p>\n<p>Let\u2019s Encrypt is a Certificate Authority (CA) that provides a free TLS\/SSL certificates, thereby enabling encrypted HTTPS on web servers. The process of obtaining and installing a certificate is fully automated on both Apache and Nginx.<\/p>\n<p>The following steps describe how to configure Let\u2019s Encrypt SSL for Nginx<\/p>\n<p>We need to ensure proper DNS records are setup for the server so that automatic installation can obtain the SSL. An A record with\u00a0velaninfo.com\u00a0&amp; <a href=\"http:\/\/www.velaninfo.com\">www.velaninfo.com<\/a> pointed to our server\u2019s public IP address.<\/p>\n<p>Install the Certbot software on the server to use Let\u2019s Encrypt to obtain the SSL certificate<\/p>\n<p>The next step is to add the repo using the following command<\/p>\n<p><em>$ sudo add-apt-repository ppa:certbot\/certbot<\/em><\/p>\n<p>Install Certbot\u2019sNginx package<\/p>\n<p><em>$ sudo apt install python-certbot-nginx<\/em><\/p>\n<p>The next step is to confirm Nginx is properly configured so that the SSL is installed automatically.<\/p>\n<p><em>$ sudonano \/etc\/nginx\/sites-available\/velaninfo.com<\/em><\/p>\n<p>server_name velaninfo.com.com <a href=\"http:\/\/www.velaninfo.com\">www.velaninfo.com<\/a>;<\/p>\n<p>If the above entry exist, exit your editor and move on to the next step.<\/p>\n<p>Verify the syntax of your configuration edits:<\/p>\n<p><em>$ sudonginx \u2013t<\/em><\/p>\n<p>Reopen the server block file and check for any typos or missing characters if you see an error. Reload Nginx to load the new configuration<\/p>\n<p><em>$ sudosystemctl reload nginx<\/em><\/p>\n<p>Certbot can now find the correct\u00a0server\u00a0block and update it.<\/p>\n<p>If you have ufw enabled in your server please follow below steps to allow https request from external network.<\/p>\n<p><em>$ sudoufw status<\/em><\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p><em>Status: active<\/em><\/p>\n<p><em>To\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Action\u00a0\u00a0\u00a0\u00a0\u00a0 From<\/em><\/p>\n<p><em>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;-<\/em><\/p>\n<p><em>OpenSSH\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ALLOW\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Anywhere<\/em><\/p>\n<p><em>Nginx HTTP\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ALLOW\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Anywhere <\/em><\/p>\n<p><em>OpenSSH (v6)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ALLOW Anywhere (v6) <\/em><\/p>\n<p><em>Nginx HTTP (v6)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ALLOW\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Anywhere (v6)<\/em><\/p>\n<p>Please execute below commands to allow Nginx https traffic through ufw.<\/p>\n<p><em>$ sudoufw allow &#8216;Nginx Full&#8217;<\/em><\/p>\n<p><em>$ sudoufw delete allow &#8216;Nginx HTTP&#8217;<\/em><\/p>\n<p>The Nginx plugin will take care of reconfiguring Nginx and reloading the configuration whenever necessary. To use this plugin, type the following:<\/p>\n<p><em>$ sudocertbot &#8211;nginx -d velaninfo.com -d <\/em><a href=\"http:\/\/www.velaninfo.com\"><em>www.velaninfo.com<\/em><\/a><\/p>\n<p><strong><em>Output<\/em><\/strong><\/p>\n<p><em>Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.<\/em><\/p>\n<p><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/em><\/p>\n<p><em>1: No redirect &#8211; Make no further changes to the webserver configuration.<\/em><\/p>\n<p><em>2: Redirect &#8211; Make all requests redirect to secure HTTPS access. Choose this for<\/em><em>new sites, or if you&#8217;re confident your site works on HTTPS. You can undo this<\/em><em>change by editing your web server&#8217;s configuration.<\/em><\/p>\n<hr \/>\n<p><em>Select the appropriate number [1-2] then [enter] (press &#8216;c&#8217; to cancel):<\/em><\/p>\n<p><em>Select enter<\/em><\/p>\n<p><strong>Output<\/strong><\/p>\n<p><em>IMPORTANT NOTES:<\/em><\/p>\n<p><em> &#8211; Congratulations! Your certificate and chain have been saved at:<\/em><em>\u00a0\u00a0 \/etc\/letsencrypt\/live\/velaninfo.com\/fullchain.pem<\/em><\/p>\n<p><em>Your key file has been saved at:<\/em><\/p>\n<p><em>\/etc\/letsencrypt\/live\/velaninfo.com\/privkey.pem<\/em><\/p>\n<p><em>Your cert will expire on 2018-07-23. To obtain a new or tweaked<\/em><em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/em><\/p>\n<p><em> version of this certificate in the future, simply run certbot again<\/em><\/p>\n<p><em>with the &#8220;certonly&#8221; option. To non-interactively renew *all* of<\/em><\/p>\n<p><em>your certificates, run &#8220;certbot renew&#8221;<\/em><\/p>\n<p><em>&#8211; Your account credentials have been saved in your Certbot<\/em><\/p>\n<p><em>configuration directory at \/etc\/letsencrypt. You should make a<\/em><\/p>\n<p><em>secure backup of this folder now. <\/em><\/p>\n<p><em>This configuration directory will<\/em><\/p>\n<p><em>also contain certificates and private keys obtained by Certbot so<\/em><\/p>\n<p><em>making regular backups of this folder is ideal.<\/em><\/p>\n<p><em>&#8211; If you like Certbot, please consider supporting our work by:<\/em><\/p>\n<p><em>Donating to ISRG \/ Let&#8217;s Encrypt:\u00a0\u00a0 https:\/\/letsencrypt.org\/donate<\/em><\/p>\n<p><em>Donating to EFF:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/em><a href=\"https:\/\/eff.org\/donate-le\"><em>https:\/\/eff.org\/donate-le<\/em><\/a><\/p>\n<p>The\u00a0Certbot\u00a0package we installed takes care of this for us by adding a renew script to\u00a0\/etc\/cron.d. This script runs twice a day and will automatically renew any certificate that\u2019s within thirty days of expiration. The SSL certificate is valid for 90 days.<\/p>\n<p>you can do a dry run with\u00a0Certbot to test the renewal process<\/p>\n<p><em>$ sudocertbot renew &#8211;dry-run<\/em><\/p>\n<p>If you see no errors, you\u2019re all set.<\/p>\n<p>At <strong>Velan<\/strong>, our server support engineers can help you securing Nginx with Let\u2019s Encrypt SSL. We troubleshoot problems like these for our clients every day.\u00a0If you are interested in our service, please fill the <a href=\"https:\/\/www.velaninfo.com\/contact\"><strong>Quick connect<\/strong><\/a> form to get in touch with us<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Secure Nginx with Let&#8217;s Encrypt on Ubuntu? Let\u2019s Encrypt is a Certificate Authority (CA) that provides a free TLS\/SSL certificates, thereby enabling encrypted HTTPS on web servers. The process of obtaining and installing a certificate is fully automated on both Apache and Nginx. The following steps describe how to configure Let\u2019s Encrypt SSL&#8230;<a class=\"continue-reading text-uppercase\" href=\"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/\"> Continue Reading <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.velaninfo.com\/rs\/wp-content\/themes\/velaninfo\/images\/reading_arw.png\" alt=\"Continue Reading\" width=\"16\" height=\"12\"\/><\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"tags":[],"class_list":["post-892","techtips","type-techtips","status-publish","hentry","Categories_tech_tip-security"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v19.5 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Secure Nginx with Let&#039;s Encrypt on Ubuntu | Velan<\/title>\n<meta name=\"description\" content=\"Steps to Secure Nginx with Let&#039;s Encrypt on Ubuntu\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Secure Nginx with Let&#039;s Encrypt on Ubuntu?\" \/>\n<meta property=\"og:description\" content=\"Steps to Secure Nginx with Let&#039;s Encrypt on Ubuntu\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"Velan\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-16T12:56:40+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\\\/\",\"url\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\\\/\",\"name\":\"How to Secure Nginx with Let's Encrypt on Ubuntu | Velan\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/#website\"},\"datePublished\":\"2021-02-15T04:56:54+00:00\",\"dateModified\":\"2021-02-16T12:56:40+00:00\",\"description\":\"Steps to Secure Nginx with Let's Encrypt on Ubuntu\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tech Tips\",\"item\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/techtips\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Secure Nginx with Let&#8217;s Encrypt on Ubuntu?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/#website\",\"url\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/\",\"name\":\"Velan\",\"description\":\"Velaninfo Services India Pvt Ltd\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.velaninfo.com\\\/rs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Secure Nginx with Let's Encrypt on Ubuntu | Velan","description":"Steps to Secure Nginx with Let's Encrypt on Ubuntu","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"How to Secure Nginx with Let's Encrypt on Ubuntu?","og_description":"Steps to Secure Nginx with Let's Encrypt on Ubuntu","og_url":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/","og_site_name":"Velan","article_modified_time":"2021-02-16T12:56:40+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/","url":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/","name":"How to Secure Nginx with Let's Encrypt on Ubuntu | Velan","isPartOf":{"@id":"https:\/\/www.velaninfo.com\/rs\/#website"},"datePublished":"2021-02-15T04:56:54+00:00","dateModified":"2021-02-16T12:56:40+00:00","description":"Steps to Secure Nginx with Let's Encrypt on Ubuntu","breadcrumb":{"@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.velaninfo.com\/rs\/techtips\/how-to-secure-nginx-with-lets-encrypt-on-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.velaninfo.com\/rs\/"},{"@type":"ListItem","position":2,"name":"Tech Tips","item":"https:\/\/www.velaninfo.com\/rs\/techtips\/"},{"@type":"ListItem","position":3,"name":"How to Secure Nginx with Let&#8217;s Encrypt on Ubuntu?"}]},{"@type":"WebSite","@id":"https:\/\/www.velaninfo.com\/rs\/#website","url":"https:\/\/www.velaninfo.com\/rs\/","name":"Velan","description":"Velaninfo Services India Pvt Ltd","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.velaninfo.com\/rs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips"}],"about":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/types\/techtips"}],"author":[{"embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/comments?post=892"}],"version-history":[{"count":3,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/892\/revisions"}],"predecessor-version":[{"id":906,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/techtips\/892\/revisions\/906"}],"wp:attachment":[{"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/media?parent=892"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.velaninfo.com\/rs\/wp-json\/wp\/v2\/tags?post=892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}