Last active
November 23, 2018 04:59
-
-
Save valesi/bad795350fa52dbeb75f145576178586 to your computer and use it in GitHub Desktop.
Let's Encrypt alias webroot location for nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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