facebook youtube pinterest twitter reddit whatsapp instagram

Securing Nginx Server Using (Let's Encrypt) [Ubuntu]

In this guide, you'll learn how to use secure your Nginx server for free with Let's Encrypt, this way, you can ensure your websites are encrypted and available over HTTPS.

Let's Encrypt provide free SSL/TLS certificates. You can get a valid SSL certificate for your domain at no cost. These certificates can be used in a production environment as well.

Note: Let’s Encrypt do a DNS check for the domain, that domain is pointed to the current server. After that it issues a certificate for the domain, so, it won't work for local development, although there is another approach for that, which is beyond the scope of this guide.

First, install certbot-auto, and save it under /usr/sbin directory, the cerbot-auto is a Let’s Encrypt client, it is used to automatically enable HTTPS on your website with EFF's Certbot, deploying Let's Encrypt certificates.

First, add the repository:

sudo add-apt-repository ppa:certbot/certbot

Install Certbot’s Nginx package with apt:

sudo apt install python-certbot-nginx

Before we get an SSL certificate for the domain, you need to make sure your server block reflects the domain name, e.g if your website is abc.com

Your servername within the server block should be:

server_name abc.com www.abc.com;

The above config is typically located in /etc/nginx/sites-available/website_name.com

If all is done, you should be ready to go, but you can still confirm the configuration syntax with sudo nginx -t This would help you notify you of any error or typo

The next step is to get an SSL certificate, use the following command to do that:

sudo certbot --nginx -d abc.com -d www.abc.com

This runs certbot with the --nginx plugin, using -d to specify the names we’d like the certificate to be valid for. In my case, it is abc.com, so you can change that.

This would do a strong Domain Validation automatically with multiple challenges to verify the ownership of the domain. Once the Certificate Authority (CA) verified the authenticity of your domain, the SSL certificate will be issued.

You will be prompted for an email address, which is used for sending email alerts related to SSL renewal and expiration. Also, it would ask a few more questions. After completion, it will issue an SSL certificate.

Related Post(s)

  • Setting Up Send-Only Mail Server From Scratch (With Haraka)

    In this guide, I would walk you through the steps of setting up an email server that can be used as a send-only mail server, we would not be dealing with receiving mails, we only care about sending em

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text-based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Using Pageant To Automatically Authenticate SSH key in Putty

    I can't count how many times I have typed my ssh key passphrase whenever my ssh connection times out, it is so annoying and repetitive. Well, thanks to the putty pageant, you can do that seamlessly.

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • How To Send Mail To Multiple Addresses Using (mailx)

    In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail. I assume you already have mailx command, i

  • Monitoring Multiple Log Files In RealTime With MultiTail (Ubuntu)

    Oh my... I really find scanning through the logs file time consuming, and painful. Luckily for me, I founded Multitail, which is an awesome, and powerful tool for not only browsing through several f