Skip to content

Instantly share code, notes, and snippets.

@valesi
Last active November 23, 2018 04:59
Show Gist options
  • Save valesi/bad795350fa52dbeb75f145576178586 to your computer and use it in GitHub Desktop.
Save valesi/bad795350fa52dbeb75f145576178586 to your computer and use it in GitHub Desktop.
Let's Encrypt alias webroot location for nginx
# /etc/nginx/snippets/le-auth.conf
location /.well-known/acme-challenge {
# Create a ".well-known" dir in /etc/letsencrypt
alias /etc/letsencrypt/.well-known/acme-challenge;
location ~ /.well-known/acme-challenge/(.*) {
add_header Content-Type application/jose+json;
}
}
server {
listen 80;
listen [::]:80;
server_name _;
# Redirect IP to domain
if ($http_host ~ \d+\.\d+\.\d+\.\d+) {
return 302 https://$main_domain$request_uri;
}
include snippets/le-auth.conf;
return 302 https://$host$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment