Last updated: March 29, 2026
This guide enables HTTPS (SSL/TLS) on your Nginx website using Let's Encrypt and Certbot. It's a follow-up to the Nginx installation guide - you should already have Nginx running with a website configured.
Update packages:
sudo apt update && sudo apt upgrade -y
Install Certbot and the Nginx plugin:
sudo apt install -y certbot python3-certbot-nginx
Allow both HTTP and HTTPS traffic:
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw status
You should see both "Nginx Full" rules listed.
Run Certbot to get a certificate and automatically configure Nginx:
sudo certbot --nginx -d example.com -d www.example.com
Replace example.com with YOUR domain and www.example.com if applicable.
Email address: Enter a valid email for renewal notifications
Accept Terms: Type A for agree
EFF Newsletter: Type Y or N based on preference
Redirect HTTP to HTTPS: Type 2 to automatically redirect all HTTP traffic to HTTPS (recommended)
Certbot will congratulate you when done. Your site is now HTTPS-enabled!
Visit your site with HTTPS:
https://example.com
You should see a green padlock in your browser.
Test your SSL rating at SSL Labs.
Certbot automatically updated your Nginx config with two server blocks:
HTTPS Block (secure): Listens on port 443 with your SSL certificate
HTTP Block (redirect): Listens on port 80 and redirects all traffic to HTTPS
View your config to see the changes:
sudo cat /etc/nginx/sites-available/example.com
Let's Encrypt certificates expire every 90 days. Certbot auto-renews them:
Check auto-renewal status:
sudo systemctl status certbot.timer
Test the renewal process (dry run):
sudo certbot renew --dry-run
Manually renew if needed:
sudo certbot renew
nslookup example.com
sudo ufw status should show "Nginx Full" allowed.
After SSL is set up, consider:
sudo apt update && sudo apt upgradeFor SSL/TLS setup assistance, please open a support ticket through your billing panel.