Home >Backend Development >PHP Tutorial >Nginx reverse proxy problem about port

Nginx reverse proxy problem about port

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-08 09:32:351114browse
Nginx’s default reverse port is 80, so there is a problem that the proxy port is 80, which leads to access errors. The main reason is that the response port is not set in the host configuration of the Nginx configuration file.
The relevant 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 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 port nginx listens to is 9090. This error makes me very depressed. Therefore, modify the nginx configuration file and change the value after Host to $host:$server_port. The configuration file is as follows:

location /ime-server {
                #root html;
                #index index.html index.htm; mote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
 Restart nginx,./nginx -s reload. Then check whether the port information after being proxied is correct
The above introduces the port issues of Nginx reverse proxy, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn