search

Home  >  Q&A  >  body text

About the port problem after nginx redirection

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

}

高洛峰高洛峰2744 days ago602

reply all(3)I'll reply

  • 黄舟

    黄舟2017-05-16 17:23:39

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

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:23:39

    listen 8800;

    server_name  localhost xxxxx;
    
    #charset koi8-r;
    
    #access_log  logs/host.access.log  main;
    
    location / {
        proxy_pass xxxxx;
    }

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:23:39

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

    reply
    0
  • Cancelreply