如何在Nginx中临时禁用从http到https的重定向?

时间:2018-09-22 13:15:05

标签: nginx

配置文件配置为重定向http-> https。告诉我文件中需要更改的内容,以便可以同时通过http和https访问该网站。

server {
    listen 80;
    listen [::]:80;
    server_name first.com www.first.com;
    return 301 https://first.com$request_uri;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name www.first.com;
        include snippets/ssl-first.com.conf;
        include snippets/ssl-params.conf;
        return 301 https://first.com$request_uri;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        include snippets/ssl-first.com.conf;
        include snippets/ssl-params.conf;                
        ...
        ...     

}

1 个答案:

答案 0 :(得分:0)

server_name first.com www.first.com;

应替换为

server_name www.first.com;

然后在#SSL配置之后添加:

listen 80;
listen [::]:80;