Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeroensmeets/6e17fc17b5cb156d24f90f222cd9d9e9 to your computer and use it in GitHub Desktop.
Save jeroensmeets/6e17fc17b5cb156d24f90f222cd9d9e9 to your computer and use it in GitHub Desktop.
essential parts for let's encrypt renewal under nginx
server {
listen 80;
# set root and server_name here
# only serve validation files for Let's Encrypt on port 80
location /.well-known/acme-challenge/ {
try_files $uri /dev/null =404;
}
# otherwise to SSL
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
# set root and server_name here
# set location of ssl certificates
# let's encrypt domain validation
location /.well-known/acme-challenge/ {
try_files $uri /dev/null =404;
}
location / {
# regular site requests
}
# this prevents hidden files (beginning with a period) from being served
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment