Skip to content

Conversation

@hdgarrood
Copy link
Collaborator

Amends the nginx config so that nginx will respond to HTTP requests
whose path starts with /.well-known/ with the matching file in
/var/www/letsencrypt-webroot, if any. This allows Let's Encrypt to
verify domain ownership in order to renew certificates automatically.

The certbot program is configured by default to renew all certificates
once they are approaching their expiration dates, so with these changes,
all that needs to happen on the server to enable subsequent renewals to
be handled completely automatically is:

  • Certbot needs to be told to use the "webroot" plugin for domain
    verification with the appropriate directory when renewing certificates
  • Nginx needs to be set up to reload its configuration periodically so
    that newly renewed certificates are picked up.

Note that certbot offers an "nginx" plugin too, but I don't trust it
because it modifies the nginx configuration, and I think it requires
taking the server down for a short time. The "webroot" approach seems
simpler and safer.

I know that this approach works because Pursuit is already using it (see
purescript/pursuit#410), so after this is merged I intend to deploy, SSH
in, and do the above two steps manually.

Amends the nginx config so that nginx will respond to HTTP requests
whose path starts with /.well-known/ with the matching file in
/var/www/letsencrypt-webroot, if any. This allows Let's Encrypt to
verify domain ownership in order to renew certificates automatically.

The `certbot` program is configured by default to renew all certificates
once they are approaching their expiration dates, so with these changes,
all that needs to happen on the server to enable subsequent renewals to
be handled completely automatically is:

- Certbot needs to be told to use the "webroot" plugin for domain
  verification with the appropriate directory when renewing certificates
- Nginx needs to be set up to reload its configuration periodically so
  that newly renewed certificates are picked up.

Note that certbot offers an "nginx" plugin too, but I don't trust it
because it modifies the nginx configuration, and I think it requires
taking the server down for a short time. The "webroot" approach seems
simpler and safer.

I know that this approach works because Pursuit is already using it (see
purescript/pursuit#410), so after this is merged I intend to deploy, SSH
in, and do the above two steps manually.
Copy link
Member

@thomashoneyman thomashoneyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@hdgarrood hdgarrood merged commit 0f64855 into purescript:master Jul 11, 2020
@hdgarrood hdgarrood deleted the automate-cert-renewal branch July 11, 2020 17:30
@hdgarrood
Copy link
Collaborator Author

If anyone is wondering how I did those two manual steps, here's how.

Tell certbot to use the webroot plugin:

$ certbot certonly -d try.purescript.org --webroot -w /var/www/letsencrypt-webroot
$ certbot certonly -d compile.purescript.org --webroot -w /var/www/letsencrypt-webroot

Configure nginx to reload periodically: run crontab -e to edit the cron configuration, and add:

0 0 * * * nginx -s reload    # reload nginx in order to pick up renewed letsencrypt certificates 

so that the command nginx -s reload is run at midnight UTC each day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants