When using Nginx as a reverse proxy, the client IP for Tomcat logging is not the real client IP, but the IP of the Nginx agent. To solve this problem, you can configure a new header in Nginx to store the $remote_add, and then Tomcat gets the record of this value.
1.Nginx New configuration:
Proxy_set_header X-real-ip $remote _addr;
See also: Http://wiki.nginx.org/NginxHttpProxyModule
In fact, there is a new one named X-real-ip value for real client IP header information.
2. Modify Tomcat Log configuration:
<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "Logs" prefix= "Tomcat_access_log". suffix= ". txt" pattern= "%a%r%t%{x-real_ip}i" resolvehosts= "false"/>
See also: http://www.docjar.org/docs/api/org/apache/catalina/valves/AccessLogValve.html
Without nginx this layer of time directly with%a can get client IP, now we have to use%{x-real-ip}i to get the real IP.