- download certbot tool:
sudo git clone https://github.com/certbot/certbot /opt/certbot
- generate certs:
sudo /opt/certbot/certbot-auto --nginx
- in the menu select domain for which you want to generate SSL certs
- in next menu select if you want
http
&&https
access to your site orhttps
exclusively
That's all, your site is now running under https.
If you want to make https connection more secure generate 4096 DHA key (could take almost 20 minutes):
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096
- include newly generated pem key in server configuration next to SSL configuration
server {
...
ssl_dhparam /etc/ssl/certs/dhparam.pem;
...
}
- verify nginx syntax:
sudo nginx -t
- restart nginx service:
sudo service nginx restart
To autoupdate certificate create new cron record:
sudo crontab -e
- check cert renew once per week
0 3 * * 1 /opt/certbot/certbot-auto --nginx renew --quiet --non-interactive >> /var/log/letsencrypt-renew.log
=======
If cert generate fails add these lines in your site's nginx config:
location ~ .well-known/acme-challenge/ {
root /var/www/letsencrypt;
default_type text/plain;
}
Alternative approach to get https certificates:
sudo /opt/certbot/certbot-auto certonly --standalone -d www.site.com -d site.com
// inspiration: https://arashmilani.com/post?id=95