Created
March 2, 2018 14:56
-
-
Save itoonx/ddccbab95f2f3babf4faf5ae3babc468 to your computer and use it in GitHub Desktop.
Nginx - redirect http to https
This file contains hidden or 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; | |
server_name www.domain.com domain.com; | |
# redirects both www and non-www to ssl port with http (NOT HTTPS, forcing error 497) | |
return 301 http://domain.com$request_uri; | |
} | |
server { | |
listen 433 ssl http2 default_server; | |
listen [::]:443 ssl http2 default_server; | |
server_name domain.com; | |
error_page 497 https://domain.com$request_uri; | |
include snippets/ssl-domain.com.conf; | |
include snippets/ssl-params.conf; | |
# other vhost configuration | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment