VPS侦探论坛

 找回密码
 注册
查看: 4621|回复: 2

无法取消http301跳转https

[复制链接]
发表于 2016-8-12 23:37:48 | 显示全部楼层 |阅读模式

军哥,请问我之前申请了letsencrypt证书,后来设置了访问http自动301重定向https,但是现在我需要以普通http的方式打开链接,就是说不要301重定向https,但是我无论怎么修改/usr/local/nginx/conf/vhost/下相应的文件,修改完上传,nginx服务器也重启了,甚至连主机也重启了,还是自动跳转https,我甚至把网站的数据库和文件全部删除也不行,只要访问这个域名就自动跳转https访问。请问我该如何修改?
附带我以前http301重定向https成功的方法,我该如何修改?请告诉我,谢谢!
  1. server
  2.     {
  3.         listen 80;
  4.         server_name xxx.com www.xxx.com;
  5.         index index.html index.htm index.php default.html default.htm default.php;
  6.         location /.well-known/ {
  7.         add_header Content-Type 'text/plain;';
  8.         root /home/wwwroot/www.xxx.com;
  9.     }
  10.         location / {
  11.         return 301 https://www.xxx.com$request_uri;
  12.     }
  13.     }

  14. server
  15.     {
  16.         listen 443 ssl http2;
  17.         server_name xxx.com www.xxx.com;
  18.         index index.html index.htm index.php default.html default.htm default.php;
  19.         root /home/wwwroot/www.xxx.com;
  20.         ssl_certificate /etc/letsencrypt/live/www.xxx.com/fullchain.pem;
  21.         ssl_certificate_key /etc/letsencrypt/live/www.xxx.com/privkey.pem;
  22.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  23.         ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  24.         ssl_prefer_server_ciphers on;
  25.         ssl_session_timeout 10m;
  26.         ssl_session_cache builtin:1000 shared:SSL:10m;
  27.         ssl_buffer_size 1400;
  28.         add_header Strict-Transport-Security max-age=15768000;
  29.         ssl_stapling on;
  30.         ssl_stapling_verify on;
  31.         
  32.         include wordpress.conf;
  33.         #error_page 404 /404.html;
  34.         location ~ [^/]\.php(/|$)
  35.         {
  36.         # comment try_files $uri =404; to enable pathinfo
  37.         try_files $uri =404;
  38.         fastcgi_pass unix:/tmp/php-cgi.sock;
  39.         fastcgi_index index.php;
  40.         include fastcgi.conf;
  41.         #include pathinfo.conf;
  42.         }
  43.         
  44.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  45.         {
  46.         expires 30d;
  47.         }
  48.         
  49.         location ~ .*\.(js|css)?$
  50.         {
  51.         expires 12h;
  52.         }
  53.         
  54.         access_log  /home/wwwlogs/www.xxx.com.log;
  55.     }
复制代码

[ 本帖最后由 Chilsion 于 2016-8-12 23:43 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-8-13 09:24:04 | 显示全部楼层


因为你加了 add_header Strict-Transport-Security max-age=15768000;
这是HSTS强制http到https的
及时你在服务器上去除了该配置,浏览器上有HSTS缓存的话也是不起作用,也就是只有你有HSTS的时候访问过,就没法改变,除非缓存到期或删除当前浏览器,chrome的话可以chrome://net-internals/#hsts 里可以自己删除HSTS记录

HSTS是一个很严谨的东西,不适合你想加就加想去就去
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-8-13 10:06:40 | 显示全部楼层

回复 2# 的帖子


谢谢军哥!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-29 03:20 , Processed in 0.025694 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表