在配置文件中加入下面代码
server {
...
if ($server_port = 80){
return 301 https://$server_name$request_uri;}
if ($scheme = http){
return 301 https://$server_name$request_uri;}
error_page 497 https://$server_name$request_uri;
....
}
本文出自 “jinchuang” 博客,请务必保留此出处http://jinchuang.blog.51cto.com/8690689/1897391
原文:http://jinchuang.blog.51cto.com/8690689/1897391