Nginx reverse proxy about port problem http://www.cnblogs.com/likehua/p/4056625.html
Nginx Default reverse port is 80, so there is a port of 80 after the agent problem, which causes access error. The main reason is that the host configuration of the Nginx configuration file does not have a response port set.
The relevant configuration files are as follows:
| 1234 |
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 above, the host is configured with only host, there is no corresponding port, which causes the wrong ports to be obtained at the proxy location. This article takes Java as an example:
| 12345 |
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 point, the port obtained is 80, although the Nginx listener is 9090. The mistake made me very depressed. Then, modify the Nginx configuration file, the host after the change to $host: $server _port, the configuration file is as follows:
| 12345678 |
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 that the port information after the agent is correct:
Nginx reverse proxy for port issues