nginx反向代理监听端口不是80,系统访问不到的问题

    server {

        listen       58012;

        server_name  192.168.137.1;

location ~  {

            proxy_pass   http://127.0.0.1:8011;

            proxy_connect_timeout 300s;

proxy_send_timeout 900;

proxy_read_timeout 900;

proxy_buffer_size 32k;

proxy_buffers 4 64k;

#proxy_buffering off;

proxy_busy_buffers_size 128k;

proxy_redirect off;

proxy_hide_header Vary;

proxy_set_header Accept-Encoding '';

proxy_set_header Referer $http_referer;

proxy_set_header Cookie $http_cookie;

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;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

红色部分  $server_port 是重点,转发的时候会把端口带过去

评论区