Nginx can be easily configured as a reverse proxy server
Server {
Listen 80;
Server_name localhost;
Location /{
Proxy_pass http: // 147.16.24.175: 9500;
Proxy_set_header Host $ host: 80;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Proxy_set_header Via "nginx ";
}
}
However, if the nginx listening port is not the default port 80, change it to another port, such as port 81.
Request. getServerPort () in the backend server cannot obtain the correct port, and the returned port is still 80;
When response. sendRedirect (), the client may not be able to obtain the correct Redirection url.
The correct configuration method is
Add the port number after $ host, for example, $ host: 81.
Server {
Listen 83;
Server_name localhost;
Location /{
Proxy_pass http: // 147.16.24.175: 9500;
Proxy_set_header Host $ host: 83;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Proxy_set_header Via "nginx ";
}
}