问题描述
场景:在第三方架设nginx反向代理,服务器在远程,第三方开放了8800端口
访问xx.xx.xx.xx:8800 出现302重定向 紧接着400 地址为xx.xx.xx.xx丢失了8800端口(就是转向默认的80端口)
如果手动加上8800端口就可以正常访问
附配置server {
listen 8800; server_name localhost xxxxx; #charset koi8-r; #access_log logs/host.access.log main; location / {proxy_pass xxxxx;proxy_set_header Host $host:8800;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
}
问题解答
回答1:listen 8800;server_name localhost xxxxx;#charset koi8-r;#access_log logs/host.access.log main;location / { #rewrite ^/(.*)$ http://xx.xx.xx.xx:80/; proxy_pass xxxxx; proxy_set_header Host $host;(去掉8800) proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}回答2:
listen 8800;
server_name localhost xxxxx;#charset koi8-r;#access_log logs/host.access.log main;location / { proxy_pass xxxxx;}回答3:
配置没看到明显问题,nginx不会主动将请求重定向到80端口