Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Commit

Permalink
Use the last settings instead of the standalone mode to avoid stoppin…
Browse files Browse the repository at this point in the history
…g nginx
  • Loading branch information
lnicola committed Jan 23, 2017
1 parent 209fbd8 commit c53f21d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# certbot-systemd-nginx
This is a small `systemd` unit for automating the Certbot certificate renewal for the nginx web server.
It runs monthly and simply executes
It runs daily with a random delay and simply executes

certbot renew --standalone
certbot renew

It uses the standalone authenticator, because Certbot nginx support is incomplete. This requires the
web server to be stopped for a couple of seconds during each run (monthly, but can be overridden) and
a bit more during renewal (once every two months).
It uses the Certbot settings from the last execution. The `webroot` or `nginx` authenticators are
recommende since this unit no longer stops `nginx`. If you are using the `standalone` mode, `certbot`
will not be able to bind to the `HTTP` port.

Please see the Certbot documentation for information about migrating to another authenticator.

# Installation
## Arch Linux
Expand All @@ -18,5 +20,5 @@ location:

# cp certbot-nginx.{service,timer} /etc/systemd/system/
# systemctl daemon-reload
# systemctl start certbot-nginx.service # to start manually
# systemctl start certbot-nginx.service # to run manually
# systemctl enable --now certbot-nginx.timer # to use the timer
7 changes: 3 additions & 4 deletions certbot-nginx.service
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[Unit]
Description=Renew Certbot certificate (nginx)
Description=Renew Certbot certificates (nginx)
After=network-online.target

[Service]
Type=oneshot
ExecStartPre=/bin/systemctl stop nginx
ExecStart=/usr/bin/certbot renew --standalone
ExecStopPost=/bin/systemctl --no-block start nginx
ExecStart=/usr/bin/certbot renew
ExecStopPost=/bin/systemctl --no-block reload nginx
3 changes: 2 additions & 1 deletion certbot-nginx.timer
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Description=Renew Certbot certificate (nginx)

[Timer]
OnCalendar=monthly
OnCalendar=daily
Persistent=true
RandomizedDelaySec=86400

[Install]
WantedBy=multi-user.target

0 comments on commit c53f21d

Please sign in to comment.