Skip to content

Instantly share code, notes, and snippets.

@bangonkali
Created February 7, 2021 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bangonkali/0eb484ac019702bf4c5e465dadf1a164 to your computer and use it in GitHub Desktop.
Save bangonkali/0eb484ac019702bf4c5e465dadf1a164 to your computer and use it in GitHub Desktop.
Certbot & NGINX Autorenew System

Certbot & NGINX Autorenew System

Manual Renewal

certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"

Automated Renewal

Validate if the following file actually exists:

/usr/bin/certbot

Create or update File: /etc/systemd/system/certbot-renewal.service

[Unit]
Description=Certbot Renewal

[Service]
ExecStart=/usr/bin/certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"

Create or update File: /etc/systemd/system/certbot-renewal.timer

[Unit]
Description=Timer for Certbot Renewal

[Timer]
OnBootSec=300
OnUnitActiveSec=1w

[Install]
WantedBy=multi-user.target

Command to Enable

sudo systemctl start certbot-renewal.timer
sudo systemctl enable certbot-renewal.timer

Command to check Status

systemctl status certbot-renewal.timer
journalctl -u certbot-renewal.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment