Skip to content

Instantly share code, notes, and snippets.

@z2015
Created May 2, 2016 02:32
Show Gist options
  • Select an option

  • Save z2015/b545c2f769e965967b736dccb2dd3f80 to your computer and use it in GitHub Desktop.

Select an option

Save z2015/b545c2f769e965967b736dccb2dd3f80 to your computer and use it in GitHub Desktop.
nginx配置https://证书以及http访问实现301跳转到https://
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