Zak*_*Zak 5 redirect reverse-proxy virtualhost nginx redirect-loop
我的 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/;
}
}
Run Code Online (Sandbox Code Playgroud)
该问题似乎仅在我添加该行时出现proxy_set_header Host $host;。该变量似乎创建了一个重定向循环,并且来自错误服务器日志的 GET 请求与服务器响应内部错误 500$host类似。...page-1/page-1/page-1/page-1...
如果有人能告诉我我做错了什么,我将非常感激。提前谢谢了!