The first day of work in the morning to solve the problem, it is really the first time to meet. Using the domain name Proxy Web project, when requested, I do not know why the domain name is not used, but the direct IP port as the path, causing the Web page crashes unusable.
Because Nginx is used as the front-end server, a little bit of modification is made, and the following are the pre-and post-modification comparisons:
Before modification:
server {
Listen 80;
server_name xxx.aaaaa.com;
Location/{
proxy_pass http://10.148.22. 81: 8180;
Proxy_set_header X-real-ip $remote _addr;
Index index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
After modification:
server {
Listen 80;
server_name xxx.aaaaa.com;
Location/{
Proxy_pass http://10.148.22. 81: 8180;
Proxy_read_timeout 600s;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header Host $host: $server _port;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Index index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
The access was successful.
Of course it is recommended for static resources, such as
Location ~. *\. (gif|jpg|png|html|htm|css|js|flv|ico|swf) (.*) {
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_cache Cache_one;
Proxy_cache_valid 302 1h;
Proxy_cache_valid 301 1d;
Proxy_cache_valid any 1m;
Expires 30d;
Index index.html index.htm;
} the efficiency is better.
The main reference is the original, thank the elder brother guidance:
Http://www.cnblogs.com/likehua/p/4056625.html
The contents are as follows:
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:
1
2
3
4
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:
1
2
3
4
5
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:
1
2
3
4
5
6
7
8
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:
The above describes the Nginx reverse proxy port domain name can not be accessed to solve the problem, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.