Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http NGINX反向代理-错误太多\u重定向-如何修复?_Http_Nginx_Https_Reverse Proxy - Fatal编程技术网

Http NGINX反向代理-错误太多\u重定向-如何修复?

Http NGINX反向代理-错误太多\u重定向-如何修复?,http,nginx,https,reverse-proxy,Http,Nginx,Https,Reverse Proxy,到目前为止,我在主服务器b93.151.75.75上使用了一个PHP脚本,它位于NGINX反向代理服务器a173.176.183.183的后面。在website2.com域名上。它成功了。 现在我已经在website2.com域名上安装了一个新的PHP脚本,我崩溃了((( 如果在脚本设置中设置HTTP协议,则会出现混合内容错误。如果打开HTTPS协议,则会出现错误-ERR_TOO_MANY_重定向。 我尝试将此脚本放在website3.com域名上,效果很好。当然,我的主服务器B 93.151.

到目前为止,我在主服务器b93.151.75.75上使用了一个PHP脚本,它位于NGINX反向代理服务器a173.176.183.183的后面。在website2.com域名上。它成功了。 现在我已经在website2.com域名上安装了一个新的PHP脚本,我崩溃了((( 如果在脚本设置中设置HTTP协议,则会出现混合内容错误。如果打开HTTPS协议,则会出现错误-ERR_TOO_MANY_重定向。 我尝试将此脚本放在website3.com域名上,效果很好。当然,我的主服务器B 93.151.75.75在website3.com域名上具有Cloudflare的SSL证书。 如何使此PHP脚本在website2.com域上正确工作? 我在服务器A 173.176.183.183反向代理设置中做错了什么

我在NGINX反向代理下面附上173.176.183.183配置和重定向检查器的信息。 我将非常感谢您的建议

nginx.conf(nginx反向代理 173.176.183.183)

重定向检查器:

https://website2.com/
302 Found
https://website2.com
302 Found
https://website2.com
302 Found
https://website2.com
302 Found
https://website2.com
302 Found
https://website2.com
302 Found
https://website2.com
302 Found
https://website2.com
.........

>>> https://website2.com/

> --------------------------------------------
> 302 Found
> --------------------------------------------

Status: 302 Found
Code: 302
Server: nginx/1.16.1
Date: Fri, 30 Apr 2021 14:05:18 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
X-Powered-By: PHP/7.3.24
Location: https://website2.com
Set-Cookie: PHPSESSID=016eaf866d782aad092458f7ecf65f9c; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Vary: Accept-Encoding




>>> https://website2.com

> --------------------------------------------
> 302 Found
> --------------------------------------------

Status: 302 Found
Code: 302
Server: nginx/1.16.1
Date: Fri, 30 Apr 2021 14:05:18 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
X-Powered-By: PHP/7.3.24
Location: https://website2.com
Set-Cookie: PHPSESSID=f5bb7fb2f39189d662f3357ff61927f3; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Vary: Accept-Encoding




>>> https://website2.com

> --------------------------------------------
> 302 Found
> --------------------------------------------

Status: 302 Found
Code: 302
Server: nginx/1.16.1
Date: Fri, 30 Apr 2021 14:05:18 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
X-Powered-By: PHP/7.3.24
Location: https://website2.com
Set-Cookie: PHPSESSID=c0cb7b8a0e23d2726f3c0f8070192b04; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Vary: Accept-Encoding

....................

我需要将这一行添加到常见的Nginx反向代理选项中-

proxy_set_header X-Forwarded-Proto $scheme;

问题已经解决。

https服务器配置代理中的默认位置传递到http服务器。这可能导致重定向循环吗?@Cole Tierney,你能告诉我更多吗?如果
代理传递http://93.151.75.75
导致http主机重定向到https,然后可能导致重定向循环。
proxy_set_header X-Forwarded-Proto $scheme;