Skip to content

Instantly share code, notes, and snippets.

@xorus
Last active February 10, 2016 18:31
Show Gist options
  • Select an option

  • Save xorus/8bd4c7c54d01908af37e to your computer and use it in GitHub Desktop.

Select an option

Save xorus/8bd4c7c54d01908af37e to your computer and use it in GitHub Desktop.
Let's encrypt renew

Let's encrypt renewal with nginx

Script based on this : https://gist.github.com/xorus/27d5fb2bdba94e80425c

Putting this script in my crontab should renew automatically my domain names certificates.

Note : I installed letsencrypt to /opt/letsencrypt

I am using a nginx webserver and I didn't want downtime for certificate renewal.

This is a raw summary of what I did to renew my domains.

Let's encrypt command line config

File : /etc/letsencrypt/cli.ini

authenticator = webroot
webroot-path = /var/www/html/
renew-by-default
agree-tos
email = [email protected]

You can specify any path, it does not nececarly needs to be in any webroot.

Nginx config

Now I needed to redirect the letsencrypt challenge verification to the webroot-path.

I created a nginx config file intended to be included in all my server entries :

/etc/nginx/conf.d/global/letsencrypt.conf

location /.well-known/acme-challenge {
    alias /var/www/html/.well-known/acme-challenge;
    auth_basic off; # I needed this to basic auth I had set on one of my hosts
}

I then included it in my virtual hosts, simply by adding include /etc/nginx/conf.d/global/letsencrypt.conf; into them.

All set

Everything is setup, let's encrypt again! ;)

/opt/letsencrypt/letsencrypt-auto --config /etc/letsencrypt/cli.ini -d example.org -d another-domain.org certonly && service nginx reload

Add any domains you want to renew like this : -d domain.com

I guess you can use the same method to register new domains

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