Let’s Encrypt is a widely trusted certificate authority that offers free TLS/SSL certificates to enable HTTPS encryption on websites. To streamline the installation and renewal process of these certificates, we use Certbot, a powerful and easy-to-use command-line utility.
In this step-by-step guide, we’ll walk you through how to install a Let’s Encrypt SSL certificate on an Nginx web server running Ubuntu 20.04.
Prerequisites
Before you begin, make sure you have the following:
- An Ubuntu 20.04 server
- A domain name pointing to your server’s IP address (e.g., yourdomain.com)
- Nginx installed and running on your server
Step 1: Install Certbot
Certbot is the tool that automates the process of obtaining and renewing SSL certificates from Let’s Encrypt.
Run the following commands to install it:
sudo apt update
sudo apt install -y certbot python3-certbot-nginx
Step 2: Configure the Firewall
If you have the UFW (Uncomplicated Firewall) enabled, you’ll need to allow HTTPS traffic through it:
sudo ufw allow 'Nginx Full'
This ensures that your web server can handle secure connections.
Step 3: Obtain and Install the SSL Certificate
Now you can use Certbot to automatically fetch and configure the SSL certificate for your domain:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Replace yourdomain.com with your actual domain name.
Certbot will prompt you to:
Enter an email address for urgent notices
Agree to the Let’s Encrypt terms of service
Once confirmed, Certbot will fetch the SSL certificate and update your Nginx configuration to use HTTPS.
Step 4: Verify Automatic Renewal
Let’s Encrypt certificates are valid for 90 days. Thankfully, Certbot automatically sets up a cron job to renew them before they expire.
To test if the renewal process works correctly, run:
sudo certbot renew --dry-run
If no errors appear, your automatic renewal is configured properly.
Conclusion
By following the steps above, you’ve successfully installed a free Let’s Encrypt SSL certificate on your Nginx server running Ubuntu 20.04. Enabling HTTPS not only secures the connection between your site and its visitors but also boosts trust and may improve your search engine rankings.