To secure Nginx with Let’s Encrypt on Ubuntu 18.04 using DNS validation, you will need to perform the following steps:
- Install certbot:
sudo apt-get update
sudo apt-get install certbot
- Install the certbot Nginx plugin:
sudo apt-get install python3-certbot-nginx
- Run certbot and specify the domain name for your Nginx server:
sudo certbot --nginx -d example.com
- Follow the prompts to enter your email address and agree to the terms and conditions.
- Once the certificate is obtained and installed, certbot will automatically update the Nginx configuration to use the newly obtained certificate and configure HTTPS.
- Verify that the certificate is properly installed and that HTTPS is working by visiting your domain in a web browser and checking that the certificate is valid.
- In addition, you will need to configure your DNS server to point your domain to your server and make sure that the DNS is propagated.
- Finally, set up a cron job or systemd timer to automatically renew the certificate before it expires.
sudo crontab -e
0 0,12 * * * certbot renew --quiet
Note: If you’re using DNS validation method, you will have to wait for the DNS to propagate which may take a few minutes to a few hours.