nginx forwards apache, jumps to the missing port, and directly brings the port of apache

For example: the access port of nginx is 90, and the port of apache is 80. After nginx acts as a proxy for apache, the forwarding request will directly take the 80 port of apache. For example, after logging in at 192.168.1.10:90, it jumps to 192.168.1.10:80.

You need to add: $server_port after the proxy_set_header Host $host; line of configuration and restart nginx. As follows:

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;

        }

}

Guess you like

Origin blog.csdn.net/weixin_42272246/article/details/128134808