How to Setup Nginx with Let's Encrypt on Ubuntu 22.04?

Jul 02, 2022 . Admin

Hi Guys,

In this example, I will show you How to Secure Nginx with Let's Encrypt on Ubuntu 20.04?. This post will give you simple example of Secure Nginx with Let's Encrypt on Ubuntu 20.04. step by step explain Install the Let's Encrypt using Nginx in Ubuntu 20.04. you can understand a concept of Ubuntu 22.04 Install the Let's Encrypt with Nginx.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Follow these steps to encrypt and configure the SSL certificate:

Step 1 – Install Certbot

Step 2 – Check Nginx Configuration

Step 3 – Allowing HTTPS Through the Firewall

Step 4 – Get Free SSL/TLS Certificate

Step 5 – Enable Automatic Certificate Renewal

Step 1: Install Certbot

Run the following command on the command line to install certbot:

sudo apt update
sudo apt install certbot python3-certbot-nginx
Step 2: Check Nginx Configuration

Run the following command on the command line to check that it is set up correctly:

sudo nano /etc/nginx/sites-available/example.com

You want to include a domain name with and without www. So enter the following command:

server_name example.com www.example.com
Step 3: Allowing HTTPS Through the Firewall

Check the firewall status by executing the following command on command line:

sudo ufw status

Allow Nginx full profile and type the following command to delete unnecessary Nginx HTTP profile allowance:

sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
Step 4: Get Free SSL/TLS Certificate

Now, execute the following command on command line to get free ssl/tls certificate:

sudo certbot --nginx -d example.com -d www.example.com
Step 5: Enable Automatic Certificate Renewal

Use the following command on the command line to create automatic renewal:

sudo systemctl status snap.certbot.renew.service

To test the renewal process, Use the dry command with certbot:

sudo certbot renew --dry-run
#Ubuntu