Let the localhost_access_log of tomcat get the real IP after using nginx
Configure nginx
Add the following code under the location node
Proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
Modify the server.xml configuration file for tomcat
To record the visitor's real IP in Tomcat, refer to the tomcat log configuration syntax described above, simply add the following mode to the log mode:% {X-Real-IP} I
Find the following configuration
Just modify it as follows
View the tomcat access record, which records the client IP address.
Outside:
Set up and record the real IP of visiting customers and the customer access address as follows:
H the IP address of the user accessed. (not the client IP address. To record the visitor's real IP in Tomcat, simply add the following mode to the log mode:% {X-Real-IP} I)
The IP address of the user accessed by% h. If the nginx proxy, it records the nginx server IP, that is, the intranet IP.