Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Let the localhost_access_log of tomcat get the real IP after using nginx

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report