gpt4 book ai didi

redirect - Nginx反向代理导致无限循环

转载 作者:行者123 更新时间:2023-12-03 06:26:31 26 4
gpt4 key购买 nike

我的 Nginx 站点配置文件中有以下内容:

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

server_name example.com;

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}


server {
listen 80;
server_name example2.com;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost/page-1/;
}
}

此问题似乎仅在我添加 proxy_set_header Host $host; 行时才会出现。看来 $host 变量创建了一个重定向循环,并且来自错误服务器日志的 GET 请求类似于以下内容 ...page-1/page-1/page-1/page -1... 服务器响应内部错误 500。

如果有人能告诉我我做错了什么,我将非常感激。非常感谢!

最佳答案

我遇到了同样的问题,按照 Alexey Ten 的建议,解决方案是删除 Host header 。

关于redirect - Nginx反向代理导致无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32362396/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com