Nginx + Certbot on Ubuntu

Automatically enable HTTPS on your website with EFF’s Certbot, deploying Let’s Encrypt certificates. This tutorial shows you how to install Certbot w/ Nginx on Ubuntu.

Table of Contents

To install certbot

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

Add/Update your server block

Make sure your Nginx server blocks match your domain+subdomains:

server_name example.com www.example.com;

If not, edit your Nginx config:

vi /etc/nginx/sites-available/default

And then restart your Nginx server:

sudo service nginx restart

Add certificate

Running this command will go through your Nginx config and add certificate locations to appropriate blocks:

sudo certbot --nginx

Allow HTTPS through the firewall:

sudo ufw allow 'Nginx Full'