Created
February 3, 2020 12:40
-
-
Save hilbix/b7246d4f1f27a116be7bd18f57752ef8 to your computer and use it in GitHub Desktop.
NginX HTTP -> HTTPS redirection with LetsEncrypt
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 { | |
server_tokens off; | |
server_name _; | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
set_real_ip_from 127.0.0.1; | |
real_ip_header X-Forwarded-For; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
root /etc/letsencrypt/web; | |
location / { | |
return 301 https://$host$request_uri; | |
} | |
location /.well-known/ { | |
try_files $uri @redirect; | |
} | |
location @redirect { | |
return 301 https://$host$request_uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
default.conf
replaces/etc/nginx/sites-available/default
/etc/letsencrypt/web/.well-known/
See also: https://github.com/hilbix/gen/blob/master/letsencrypt.http