发布于 2年前

Nginx重定向http到https

Nginx重定向http到https:

方法一

【推荐】使用响应码301,301内容参考HTTP 301 Moved Permanently

server {
    listen         [::]:80;
    return 301 https://$host$request_uri;
}

方法二

server {
    listen 80;
    rewrite ^(.*) https://$host$1 permanent;
 }

这里使用了rewrite和正则,有一定的性能影响。

©2020 edoou.com   京ICP备16001874号-3