我使用两台Nginx机器作为反向代理,但在浏览器中出错了主机。详细信息很糟糕。 在Proxy1(192.168.0.1)
中 upstream proxy2 {
server 192.168.0.2:8040;
}
server {
listen 8041;
server_name localhost;
root html;
index index.html index.htm index.php;
location / {
proxy_pass http://proxy2;
#Proxy Settings
#proxy_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
在Proxy2(192.168.0.2)
中upstream backend {
server 192.168.0.2:8041;
server 192.168.0.3:8041;
}
server{
listen 8040;
server_name localhost;
location / {
proxy_pass http://backend;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
在后端服务器中我只使用php redirect / to / auth / login
然后当我访问http://192.168.0.1:8041时,我显示转到http://192.168.0.1:8041/auth/login,但它重定向到http://192.168.0.1:8040 / auth / login,看起来端口传递出错了。有人可以帮帮我吗?