nginx http请求跳转https的3种方法

第一:


if ($scheme = http ) {
return 301 https://$host$request_uri;
}

#or

if ($server_port = 80 ) {
return 301 https://$host$request_uri;
}

第二:

rewrite ^(.*)$  https://$host$1 permanent;  

 

第三:

return 301 https://$server_name$request_uri;

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注