Home » Secure HTTPS Setup With nginx and Let’s Encrypt (Part 3) – Auto Renew Script

Secure HTTPS Setup With nginx and Let’s Encrypt (Part 3) – Auto Renew Script

In this tutorial (which is an extension of part 2 and part 1 of a tutorial series for setting up letsencrypt on nginx) we’ll show you how to setup a BASH script that will automate the renewal of your certificates. This should enable you to sit back and have your Lets Encrypt SSL certificates automatically renew with a cron job that runs in the background on an interval.

  1. Add the following to /root/letsencrypt/cli.ini

     

  2. In the file above, change /home/yoursite.com/ to the document root of the site in question, and change the postmaster@yoursite.com to whatever email address you’d like to use for emailing when things fail.

     

  3. Add the following to /root/letsencrypt/letsrenew.sh

     

  4. In the file above, change yoursite.com and www.yoursite.com to your domain that you want to renew the SSL certificate(s) for, and change postmaster@yoursite.com to whatever email address you’d like to use for emailing when things fail.

     

  5. Add the following to crontab -e

     

  6. (optional) Add the following to your bash profile with:  vim ~/.bash_profile

    This just allows you to type letsrenew in your terminal to renew your certificates whenever you want. The cron job we added in step 5 should automate this part for you, so this is just an added convenience.

     

As always, if you have any issues or questions about this process, feel free to drop a comment below and I’ll try to help you troubleshoot whatever issues you’re having. Please remember to include as much detail as possible when you comment as it will help to better understand your issues.

Leave a Reply

Your email address will not be published. Required fields are marked *