Step by step instructions on securing your website with SSL (HTTPS) using Lets Encrypt for free.

Lets Encrypt Logo

Before you begin this tutorial you should have your website live using Ubuntu 16.04 and Nginx.

Step 1: Installing Certbot

Certbot is a little package that nearly automates the SSL encryption process completely. Install it with the following commands:

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx 

Step 2: Run Certbot

Next run certbot with the command below. It was ask you a few questions just answer them.

sudo certbot --nginx

Thats it you’re all done, try out your website through https.

Step 2: Auto-renew with cron

Lets Encrypt certificates are only good for 3 months. So lets set up a cron task to attempt to renew every night at 12:01.

First we need to make sure the renew command works. Test it using the --dry-run flag.

sudo certbot renew --dry-run

If all went well open up your crontab.

sudo crontab -e

Append the following line, save and exit, and we’re good to go.

1 12 * * * certbot renew