Updated: 18 November 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9 and Ubuntu 24.04
CentOS 7 reached end of life on 30 June 2024, so this guide now uses AlmaLinux 9 / Rocky Linux 9 (the steps also suit other RHEL 9 rebuilds).
Let's Encrypt gives free SSL certificates. Certbot requests them and configures Nginx for you.
Before you start
- Nginx installed and serving your domain (a
server_namefor it). - The domain's A record pointing to the server, and ports 80 and 443 open.
Add a free SSL certificate
apt install certbot python3-certbot-nginx # Ubuntu / Debian dnf install epel-release && dnf install certbot python3-certbot-nginx # AlmaLinux / Rocky certbot --nginx -d example.com -d www.example.com
Certbot installs a timer that renews the certificate automatically; test it with certbot renew --dry-run.
Certbot adds the listen 443 ssl lines and certificate paths to your server block, and can redirect http to https. Check the result with nginx -t and by opening https://example.com.