Install certbot
apt install certbot
Check certbot version
certbot --version
Using certbot to issue Certificates (DNS-01 challenge)
certbot certonly --manual --preferred-challenges dns -m youremail@example.com -d example.com -d www.example.com
Add a DNS TXT record to pass the challenge
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:
_acme-challenge.www.example.ca.
with the following value:
35tnzY1irUm3AVabcUXuH7xKmefgrJJrdGDvvTYgzBg
...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If pass the challenge
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem
Check Certificates
certbot certificates
Check Nginx settings
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_intercept_errors on;
}
}
Restart Nginx
systemctl restart nginx