: This article mainly introduces the port issue of Nginx Reverse proxy. if you are interested in the PHP Tutorial, please refer to it. The default reverse port of Nginx is 80, so there is a problem of port 80 after the proxy, which leads to an access error. The main reason is that no response port is set when the host of The Nginx configuration file is configured.
The configuration files are as follows:
Proxy_pass http: // ime-server/ime-server;
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
As shown above, the Host configuration only has a host and no corresponding port, which leads to an incorrect port in the proxy. This article takes java as an example:
String scheme = httpRequest. getScheme ();
String serverName = httpRequest. getServerName ();
Int port = httpRequest. getServerPort ();
// Service request address
String requestURI = scheme + ": //" + serverName + ":" + port + "/ime-server/rest/" + serviceName + "/wmts ";
At this time, the obtained port is 80, although the nginx listening port is 9090. This error made me very depressed. Modify the nginx configuration file and change the configuration file behind the Host to $ host: $ server_port. the configuration file is as follows:
Location/ime-server {
# Root html;
# Index index.html index.htm;
Proxy_pass http: // ime-server/ime-server;
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;
}
Restart nginx,./nginx-s reload. Then, check whether the port information after the proxy is correct.
The above describes the port issue of Nginx Reverse proxy, including some content, and hope to be helpful to friends who are interested in PHP tutorials.