DEV Community

Discussion on: Nginx, Let’s Encrypt and taking my own server down 😢

Collapse
 
blikkie_52 profile image
Remco van Bree • Edited

A former co-worker of mine suggested this setup:

Add the following location to your server block:

location /.well-known/acme-challenge {
        proxy_pass http://[::1]:9999;
}

and then run certbot like this:

certbot certonly --standalone --http-01-port 9999 --noninteractive --agree-tos --email youremail@yourdomain.com -d www.yoursite.com --post-hook "service nginx reload"

The renew job in my crontab looks like this:

14  4,16  * * * sudo certbot renew --standalone --http-01-port 9999 --renew-hook "service nginx reload" >> /var/log/le-renew.log

Of course that means that you actually have to add the key paths to your nginx config too, but once you have this up and running you will have a nice and stable config.

Collapse
 
ptasker profile image
Peter Tasker

Neat! Yeah I think running the --standalone flag is the way to go. I gotta check the docs on certbot as I didn't realize you could specify a custom verification location directive.