About the port problem after nginx redirection
高洛峰
高洛峰 2017-05-16 17:21:39
0
3
619

Scenario: Set up nginx reverse proxy in a third party, the server is remote, and the third party opens port 8800

When accessing xx.xx.xx.xx:8800, a 302 redirect appears, followed by a 400 address. The address is xx.xx.xx.xx and the 8800 port is lost (that is, it is redirected to the default port 80)

If you manually add port 8800, you can access it normally

Attached configuration
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;
    }

}

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
黄舟
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;
}
Ty80

listen 8800;

server_name  localhost xxxxx;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
    proxy_pass xxxxx;
}
大家讲道理

No obvious problems are seen in the configuration, nginx will not actively redirect requests to port 80

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template