Prerequisites
- The domain's A record must point to the server IP
- Ports 80 and 443 must be open
Installing Certbot
Bash
sudo apt install -y certbot python3-certbot-nginxIssuing the Certificate
Bash
sudo certbot --nginx -d example.com -d www.example.comCertbot automatically adds an SSL block and an HTTP → HTTPS redirect to your Nginx configuration.
Manual Nginx Configuration
Bash
sudo certbot certonly --nginx -d example.comNginx
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_stapling on;
ssl_stapling_verify on;
location / {
proxy_pass http://127.0.0.1:3000;
}
}
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}Automatic Renewal (90-day validity)
Bash
systemctl status certbot.timer
sudo certbot renew --dry-runWildcard Certificate
Bash
sudo certbot certonly \
--manual \
--preferred-challenges dns \
-d "*.example.com" \
-d example.comEditorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Topic-related official docs (auto-linked · not per-claim sources)NGINX documentation ↗OpenSSL documentation ↗
Questions & answers
Ask a question about this guide. We'll review and reply.