To configure Nginx with a Let's Encrypt TLS/SSL certificate on Debian or Ubuntu, you will need to perform the following steps:
sudo apt-get install python3-certbot-nginx
<domain>
with your domain name:sudo certbot certonly --standalone -d <domain>
This will create a certificate and private key pair, and store them in the /etc/letsencrypt/live/<domain>
directory.
/etc/nginx/sites-available/<domain>
, to include the following lines:server { listen 443 ssl; ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem; ... }
Save the changes to the configuration file and exit the text editor.
Test the configuration file for syntax errors by running the following command:
sudo nginx -t
sudo systemctl reload nginx
https://
instead of http://
.Note that the TLS/SSL certificate issued by Let's Encrypt is only valid for 90 days. You will need to renew the certificate before it expires. To do this, you can run the following command:
sudo certbot renew
This will renew the certificate and update the fullchain.pem
and privkey.pem
files in the /etc/letsencrypt/live/<domain>
directory. You will need to reload Nginx to apply the changes.