Created
May 2, 2016 02:32
-
-
Save z2015/b545c2f769e965967b736dccb2dd3f80 to your computer and use it in GitHub Desktop.
nginx配置https://证书以及http访问实现301跳转到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 443 ssl; | |
| server_name www.mydomain.com; | |
| root /www/mydomain.com/; | |
| ssl on; | |
| ssl_certificate /ssl/domain.crt; | |
| ssl_certificate /ssl/domain.key; | |
| . | |
| . | |
| . | |
| } | |
| server{ | |
| listen 80; | |
| server_name www.mydomain.com mydomain.com; | |
| return 301 https://www.$server_name$request_uri; | |
| } | |
| server{ | |
| listen 443; | |
| server_name mydomain.com; | |
| return 301 https://www.$server_name$request_uri; | |
| } | |
| //http://stackoverflow.com/questions/21106998/nginx-redirect-http-to-https-and-non-www-to-ww |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment