例如:nginx的访问的端口是90,apache的端口是80,nginx代理apache后,转发请求会直接带apache的80端口,比如192.168.1.10:90登录后却跳转到了192.168.1.10:80
需要在proxy_set_header Host $host;这行配置后面添加:$server_port,重启nginx即可。如下所示:
server {
listen 90;
charset UTF-8;
server_name 192.168.1.10;
location / {
proxy_pass http://192.168.1.10:80;
proxy_set_header Host $host:$server_port;
proxy_set_header Remote_Addr $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
index index;
}
}