Script for Automatically renew certs


#1

Hello is it possible to create a script which will automatically renew the certs in Apache2 and Haproxy.Thanks


#2

Yes, that is possible.


#3

Something like this will work ?
#!/bin/sh
SITE=example.com
# move to the correct let’s encrypt directory
cd /etc/letsencrypt/live/$SITE
# cat files to make combined .pem for haproxy
cat fullchain.pem privkey.pem > /etc/haproxy/certs/$SITE.pem
# reload haproxy
service haproxy reload


#4

Looks sound. You can use “hooks” to automatically run such a script at renewal.

See for more information the last part of the renewal section in the certbot documentation: https://certbot.eff.org/docs/using.html#renewing-certificates