Secure Nginx with Let’s Encrypt on Ubuntu 18.04 with DNS Validation

To secure Nginx with Let’s Encrypt on Ubuntu 18.04 using DNS validation, you will need to perform the following steps:

  1. Install certbot:
sudo apt-get update
sudo apt-get install certbot
  1. Install the certbot Nginx plugin:
sudo apt-get install python3-certbot-nginx
  1. Run certbot and specify the domain name for your Nginx server:
sudo certbot --nginx -d example.com
  1. Follow the prompts to enter your email address and agree to the terms and conditions.
  2. Once the certificate is obtained and installed, certbot will automatically update the Nginx configuration to use the newly obtained certificate and configure HTTPS.
  3. 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.
  4. 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.
  5. 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.

Leave a Comment