加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

ubuntu – 无法从Nginx中删除强制HTTPS重定向?

发布时间:2020-12-13 21:13:22 所属栏目:Nginx 来源:网络整理
导读:我最初设置了我的Nginx配置,以自动将HTTP重定向到HTTPS.由于我的工作安全策略和Cloudflare集成,HTTPS无法在我的网络内解析. 我只想删除强制重定向到HTTPS.但在使用URI重写注释掉块之后,服务器仍会自动重定向. 这是我对Nginx的默认配置 #HTTPS redirect (if n

我最初设置了我的Nginx配置,以自动将HTTP重定向到HTTPS.由于我的工作安全策略和Cloudflare集成,HTTPS无法在我的网络内解析.

我只想删除强制重定向到HTTPS.但在使用URI重写注释掉块之后,服务器仍会自动重定向.

这是我对Nginx的默认配置

#HTTPS redirect (if necessary)
#server {
#       listen      80;
#       server_name example.com;
#       rewrite     ^   https://$server_name$request_uri? permanent;
#}

server {
        listen 80;
        listen [::]:80 default_server ipv6only=on;
        listen 443 ssl spdy;
        root /var/www/example/current/public;
        index index.php index.html index.htm;

        spdy_chunk_size 8k;
        spdy_headers_comp 7;

        server_name example.com;
        # Point to ssl certificates
        ssl_certificate /root/example.com.crt;
        ssl_certificate_key /root/example.com.key;
        # Allow only secure TLS protocols
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        #ssl_prefer_server_ciphers on;
        #ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;

        ssl on;

        # Set the buffer size to 1400 bytes (that way it fits into a single MTU$
        ssl_buffer_size 1400;
#       add_header Strict-Transport-Security max-age=63072000;

        gzip on;
        gzip_min_length 1280;
        gzip_buffers    16 8k;
        gzip_comp_level 4;
        gzip_http_version 1.0;
        gzip_types    text/plain text/html text/css application/javascript appl$
        gzip_vary on;

        location / {
                # First attempt to serve request as file,then
                # as directory,then fall back to displaying a 404.
                try_files $uri $uri/ /index.php$is_args$args;
        }

        # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm$
        location ~ .php${
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_nam$
                include fastcgi_params;
        }

        location ~* .(css|js|gif|jpe?g|png|woff2?)${
                #gzip on;
                #gzip_vary on;
                expires 168h;
                add_header Pragma public;
                add_header Cache-Control "public,must-revalidate,proxy-revali$
                add_header Vary "Accept-Encoding";
        }


        #include /etc/nginx/global/*;
}

任何帮助将不胜感激!谢谢.

最佳答案
首先,删除ssl;

其次,你有Strict-Transport-Security标题和浏览器记住了2年(正如标题所说的那样).使用max-age = 0添加它以删除效果.

如果您不能这样做(或希望立即生效),请从浏览器中清除HSTS,如this article所说.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读