DEV Community

Bogdan Alexandru Militaru
Bogdan Alexandru Militaru

Posted on • Originally published at boobo94.github.io on

How to Setup Nginx with Let's Encrypt on Ubuntu 20.04

Prerequisites:

  • Ubuntu 20.04 Server Installed with Nginx and Hosted Website

Install Certbot on Ubuntu

Certbot is an open-source tool that simplifies and automates the process of obtaining and renewing certificates from Let’s Encrypt. We are going to install Certbot by using the Snap deployment system. Snap is pre-installed on Ubuntu 20.04.

Update snapd

Run the following commands to update snapd.

$ sudo snap install core
$ sudo snap refresh core

Enter fullscreen mode Exit fullscreen mode

Install certbot snap

Note: If you have previously installed Certbot by using the standard apt command, then run the following command first to remove it. This will ensure that the Certbot snap works correctly.

$ sudo apt-get remove certbot

$ sudo snap install --classic certbot
certbot 1.11.0 from Certbot Project (certbot-eff✓) installed

Enter fullscreen mode Exit fullscreen mode

Enable certbot command

$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

Enter fullscreen mode Exit fullscreen mode

Obtain your Certificate

When you run the command below, certbot will guide you through the process. Certbot also updates your NGINX configuration automatically to activate HTTPS.

$ sudo certbot --nginx

Enter fullscreen mode Exit fullscreen mode

Certificate Renewal Process

Certificates issued by Let’s Encrypt are valid for 90 days. During installation, certbot creates a scheduled task to automatically renew your certificates before they expire. As long as you do not change your web server configuration, you would not have to run certbot again.

Run the following command to test the automatic renewal process.

$ sudo certbot renew --dry-run

Enter fullscreen mode Exit fullscreen mode

!Note: Source post https://linoxide.com/ubuntu-how-to/setup-nginx-with-lets-encrypt-on-ubuntu-20-04/

Top comments (0)