首页 > 代码库 > nginx解决浏览器访问http自动转向https问题

nginx解决浏览器访问http自动转向https问题

nginx配置文件如下:

server {
    listen       443 ssl http2;
    server_name  zt.test.com;
    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ‘AES128+EECDH:AES128+EDH:!aNULL‘;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_dhparam /etc/nginx/conf.d/ssl/dhparam.pem;
    ssl_certificate     /etc/nginx/conf.d/ssl/test.com.crt;
    ssl_certificate_key /etc/nginx/conf.d/ssl/test.com.key;
#把下面的注释掉就可以了
    #add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    access_log  /var/log/nginx/zt.test.log main;
    set $web_url $host;

    location / {
        proxy_pass         http://staticweb.server;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        set $domain default;
        }
}

  

nginx解决浏览器访问http自动转向https问题