nginx+ (1...N) when a tomcat cluster is deployed, back-end Tomcat needs to acquire the user's IP, which is always achieved through REQUEST.GETREMOTEADDR () 127.0.0.1.
Because the user requests after NGINX,NGIGX forwarded the request to Tomcat, Tomcat obtains always the Nginx IP, if needs to obtain the real user IP, only need to make some configuration on the Ngix.
Location/Down settings
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header Host $host;
Test configuration:./sbin/nginx-t-C conf/nginx.conf correct after restarting Nginx.
The Java code is modified as follows
Out.println ("X-real-ip:" + request.getheader ("X-real-ip") + "
");
Where X-real-ip is the user's real IP
Note: X-REAL-IP is a variable, you can change the name according to your own needs.
The above describes the Nginx+tomcat to obtain the remote User IP problem resolution, including the content, I hope that the PHP tutorial interested in a friend helpful.