全球主机交流论坛

用户名  找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 726|回复: 19

[疑问] 求助大佬们一个很奇怪的PHP问题!已问遍所有主流ai

[复制链接]
发表于 2025-2-27 17:05:35 | 显示全部楼层 |阅读模式
本帖最后由 Telegramr 于 2025-2-28 10:16 编辑

先说声谢谢了

有一个PHP获取双色球开奖信息的功能,现在遇到一个很奇怪的问题,在本地调试的时候正常,但在服务器上运行的时候出现异常,提示 Error: Maximum (10) redirects followed

问遍了所有ai下都找不到问题在哪,所以现在向各位大佬们请教一下,谢谢大家了。

ssq.rar (2.09 KB, 下载次数: 8)

curl_debug.rar (1.37 KB, 下载次数: 4)

这段代码,在本地php+nginx下没有任何问题,但是在服务器上却打开网页就显示 Error: Maximum (10) redirects followed 错误,同时curl获取不到任何数据。

本地调试环境:
PHP 7.0.33 (cli) (built: Oct 10 2024 09:07:20) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
nginx:1.2.2

服务器环境:
PHP 7.3.33 (cli) (built: Aug 23 2022 12:54:26) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
nginx:nginx/1.21.6

在服务器上命令行执行curl命令同样返回这个错误提示,按道理说不应该是IP被封,因为以前没有对这个网址做过操作。谢谢大家了。

  1. curl -L -X GET "https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5" \
  2. > -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" \
  3. > -H "Referer: https://www.cwl.gov.cn/" \
  4. > -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" \
  5. > -H "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8" \
  6. > -H "Accept-Encoding: gzip, deflate, br, zstd" \
  7. > -H "Cache-Control: max-age=0" \
  8. > -H "Connection: keep-alive" \
  9. > -H "Cookie: 21_vq=9; HMF_CI=96ce8230eb88a79f892aefc97605870f4c3e6a7826499fdd1a4663e39a878a352ab87872e84207f940421846dc3cad1ea727aef41e54c73a95c2ee89acf3a2a181"
  10. curl: (47) Maximum (50) redirects followed
复制代码


chatgpt指导下的返回信息

  1. curl -L -v --max-redirs 100 -X GET "https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC" \
  2. -H "User-Agent: baidu:Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" \
  3. -H "Referer: https://www.cwl.gov.cn/" \
  4. -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" \
  5. -H "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8" \
  6. -H "Accept-Encoding: gzip, deflate, br, zstd" \
  7. -H "Cache-Control: max-age=0" \
  8. -H "Connection: keep-alive" \
  9. -H "Cookie: 21_vq=9; HMF_CI=96ce8230eb88a79f892aefc97605870f09846e72de625cb216052159c751b0656906343280a05f6ecd334d49c2f5bce058e4a38f6125c41d6ad49e5d8b6163c9a7"
复制代码

< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Fri, 28 Feb 2025 02:11:34 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
< Cache-Control: no-store
< Location: https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC
< x-ws-request-id: 67c11b56_PS-JJN-01wa2247_64743-919
< Set-Cookie: HMF_CI=96ce8230eb88a79f892aefc97605870fc4779740f71f0e749300291daecfcc32c9ea6cfe7736aa2cf993ef4782f7f87b1f448c009101c148709fbd1ad72551597f; Expires=Sun, 30-Mar-25 02:11:34 GMT; Path=/
<
* Ignoring the response-body
* Connection #0 to host www.cwl.gov.cn left intact
* Issue another request to this URL: 'https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC'
* Re-using existing connection! (#0) with host www.cwl.gov.cn
* Connected to www.cwl.gov.cn (27.148.164.154) port 443 (#0)
> GET /cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC HTTP/1.1
> Host: www.cwl.gov.cn
> User-Agent: baidu:Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
> Referer: https://www.cwl.gov.cn/
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
> Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
> Accept-Encoding: gzip, deflate, br, zstd
> Cache-Control: max-age=0
> Connection: keep-alive
> Cookie: 21_vq=9; HMF_CI=96ce8230eb88a79f892aefc97605870f09846e72de625cb216052159c751b0656906343280a05f6ecd334d49c2f5bce058e4a38f6125c41d6ad49e5d8b6163c9a7
>
< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Fri, 28 Feb 2025 02:11:34 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
< Cache-Control: no-store
< Location: https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC
< x-ws-request-id: 67c11b56_PS-JJN-01wa2247_64743-920
< Set-Cookie: HMF_CI=96ce8230eb88a79f892aefc97605870fc4779740f71f0e749300291daecfcc63c9ea6cfe7736aa2cf993ef4782f7f87b1f448c009101c148709fbd1ad72551597f; Expires=Sun, 30-Mar-25 02:11:34 GMT; Path=/
<
* Ignoring the response-body
* Connection #0 to host www.cwl.gov.cn left intact
* Issue another request to this URL: 'https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC'
* Re-using existing connection! (#0) with host www.cwl.gov.cn
* Connected to www.cwl.gov.cn (27.148.164.154) port 443 (#0)
> GET /cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC HTTP/1.1
> Host: www.cwl.gov.cn
> User-Agent: baidu:Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
> Referer: https://www.cwl.gov.cn/
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
> Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
> Accept-Encoding: gzip, deflate, br, zstd
> Cache-Control: max-age=0
> Connection: keep-alive
> Cookie: 21_vq=9; HMF_CI=96ce8230eb88a79f892aefc97605870f09846e72de625cb216052159c751b0656906343280a05f6ecd334d49c2f5bce058e4a38f6125c41d6ad49e5d8b6163c9a7
>
< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Fri, 28 Feb 2025 02:11:34 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
< Cache-Control: no-store
< Location: https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&issueCount=5&pageNo=1&pageSize=5&systemType=PC
< x-ws-request-id: 67c11b56_PS-JJN-01wa2247_64743-921
< Set-Cookie: HMF_CI=96ce8230eb88a79f892aefc97605870fc4779740f71f0e749300291daecfcc39c9ea6cfe7736aa2cf993ef4782f7f87b1f448c009101c148709fbd1ad72551597f; Expires=Sun, 30-Mar-25 02:11:34 GMT; Path=/
<
* Ignoring the response-body
* Connection #0 to host www.cwl.gov.cn left intact
* Maximum (100) redirects followed
curl: (47) Maximum (100) redirects followed
* Closing connection #0



微信图片_20250227172853.png (24.92 KB, 下载次数: 0)

微信图片_20250227172914.png (31.2 KB, 下载次数: 0)
发表于 2025-2-27 17:08:55 来自手机 | 显示全部楼层
国外服务器吧。也许限制了国外服务器访问
发表于 2025-2-27 17:09:57 | 显示全部楼层
看提示啊就是你无限跳转了,最多跳转10次。一般是302跳转或者301跳转循环了
Error: Maximum (10) redirects followed
 楼主| 发表于 2025-2-27 17:12:24 | 显示全部楼层
似毛非毛 发表于 2025-2-27 17:08
国外服务器吧。也许限制了国外服务器访问

国内的服务器
发表于 2025-2-27 17:13:09 | 显示全部楼层
服务器那边把curl结果print_r存到一个txt文件看看先
 楼主| 发表于 2025-2-27 17:14:35 | 显示全部楼层
jessegold 发表于 2025-2-27 17:09
看提示啊就是你无限跳转了,最多跳转10次。一般是302跳转或者301跳转循环了
Error: Maximum (10) redirects ...

现在就是不知道哪里跳多了,所以也没办法改。

ai教的方法都试遍了。

1、发了ngixn.conf,ai没说有问题
2、发了源文,ai没说有问题
 楼主| 发表于 2025-2-27 17:21:03 | 显示全部楼层
func 发表于 2025-2-27 17:13
服务器那边把curl结果print_r存到一个txt文件看看先

需要在哪里插入print_r呢?我按照ai的要求生成了一个日志文件。

* About to connect() to www.cwl.gov.cn port 443 (#0)
*   Trying 27.148.164.154... * connected
* Connected to www.cwl.gov.cn (27.148.164.154) port 443 (#0)
* skipping SSL peer certificate verification
* SSL connection using TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
* Server certificate:
*         subject: CN=*.cwl.gov.cn,O=中国福利彩票发行管理中心,ST=北京市,C=CN
*         start date: Nov 11 00:00:00 2024 GMT
*         expire date: Dec 03 23:59:59 2025 GMT
*         common name: *.cwl.gov.cn
*         issuer: CN=DigiCert Secure Site OV G2 TLS CN RSA4096 SHA256 2022 CA1,O="DigiCert, Inc.",C=US
> GET /cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq HTTP/1.1
Host: www.cwl.gov.cn
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Referer: https://www.cwl.gov.cn/
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cache-Control: max-age=0
Connection: keep-alive
Cookie: 21_vq=9; HMF_CI=96ce8230eb88a79f892aefc97605870f4c3e6a7826499fdd1a4663e39a878a352ab87872e84207f940421846dc3cad1ea727aef41e54c73a95c2ee89acf3a2a181

< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Thu, 27 Feb 2025 06:05:10 GMT
< Content-Type: text/html
< Content-Length: 138
< Connection: keep-alive
< Cache-Control: no-store
< Location: https://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq
< x-ws-request-id: 67c00096_PS-JJN-010i6241_34268-8399
< Set-Cookie: HMF_CI=96ce8230eb88a79f892aefc97605870ffb76811efa69c8c925180e2f39789b64bb41d4de768aca19a6ac5d95d83d79006dec427c00d67b81f9a1d9c1ed043a73f8; Expires=Sat, 29-Mar-25 06:05:10 GMT; Path=/


 楼主| 发表于 2025-2-27 17:23:01 | 显示全部楼层
func 发表于 2025-2-27 17:13
服务器那边把curl结果print_r存到一个txt文件看看先

帖子里curl_debug.rar 这个是我刚上传的一个ai教的报告,麻烦您帮忙看看,谢谢您了
发表于 2025-2-27 17:26:05 来自手机 | 显示全部楼层
是不是nginx设置了http跳https,然后又过cf,cf回源http了
 楼主| 发表于 2025-2-27 17:36:15 | 显示全部楼层
songsong 发表于 2025-2-27 17:26
是不是nginx设置了http跳https,然后又过cf,cf回源http了

我服务器上的inginx的server里有监视listen80和listen443的两条命令,没有强制跳转

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-4-3 13:46 , Processed in 0.079195 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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