VPS侦探论坛

 找回密码
 注册
查看: 5027|回复: 6

http跳转https总是提示多次定向,请帮忙看看这配置哪里出问题了

[复制链接]
发表于 2018-11-27 22:39:24 | 显示全部楼层 |阅读模式

想让http://www.xxx.com 跳转到https://www.xxx.com
但这样配置后就会提示重定向次数过多
请帮忙看看是哪里错了
谢谢啊

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.xxx.com ;
        return 301 https://www.xxx.com$request_uri;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/XXX;

        include discuzx.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }

server
    {
        listen 443 ssl http2;
        #listen [::]:443 ssl http2;
        server_name www.xxx.com ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/xxx;
        ssl on;
        ssl_certificate /usr/local/nginx/conf/ssl/www.xxx.com.crt;
        ssl_certificate_key /usr/local/nginx/conf/ssl/www.xxx.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "EECDH+CHACHA20:EECDH+CHA0-draft:EECDAES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RDES:!MD5";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

        include discuzx.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log off;
    }

[ 本帖最后由 独孤羽 于 2018-11-27 22:40 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2018-11-28 12:12:53 | 显示全部楼层


discuz论坛程序  .conf 规则里没加301还自动跳转,加一句就重复定向了。
好郁闷,不知道还有哪里加了301 定向,找了好几天也没找出来
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2018-11-28 13:36:09 | 显示全部楼层

这个配置文件上并没有导致重复301的设置
之前是否设置301出错,浏览器是否清空缓存试过
curl -IL http://www.xxx.com 看一下
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2018-11-28 14:05:27 | 显示全部楼层



浏览器也清空缓存试了,
用军哥的命令看了是这样,啥意思哈,不太懂。

root@localhost ~]# curl -IL www.xxx.net
HTTP/1.1 301 Moved Permanently
Server: NWS_SP
Connection: keep-alive
Date: Wed, 28 Nov 2018 06:04:15 GMT
Content-Length: 22
Location: https://www.xxx.net/

HTTP/1.1 564
Server: NWSs
Date: Wed, 28 Nov 2018 06:04:17 GMT
Content-Length: 0
Connection: keep-alive
X-NWS-LOG-UUID: d02d1f31-e6ea-4284-ac91-cb5ff81ff902
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2018-11-28 14:17:47 | 显示全部楼层

关闭腾讯cdn的301后是这样

curl -IL www.xxx.net
curl: (56) Recv failure: Connection reset by peer
[root@localhost ~]#

即使我关掉腾讯cdn的301,清除浏览器缓存后,自己加上一楼的那个定向还是会出现重复定向的现象。
我现在就是不想用腾讯的301,但关掉后,自己加上总是出现重复定向。
不知道是哪里的问题呢

[ 本帖最后由 独孤羽 于 2018-11-28 14:24 编辑 ]

军哥运维代购:http://shop63846532.taobao.com/

发表于 2018-11-28 19:32:11 | 显示全部楼层

回复 4# 的帖子


564的错误代码可能你源站有问题

关闭cdn还是无法访问你服务器上可能有问题

如果不用cdn正常的话就是你cdn的锅
 楼主| 发表于 2018-11-28 20:08:42 | 显示全部楼层

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

本版积分规则

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

GMT+8, 2024-9-23 11:23 , Processed in 0.027368 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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