标签:使用nginx后让tomcat的localhost_access_log获得真实ip tomcat的localhost_access_log获得真实ip
配置nginx
在location节点下面加入如下代码
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;
修改tomcat的server.xml配置文件
找到如下配置
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
修改成如下即可
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%{X-Real-IP}i %l %u %t "%r" %s %b" />
本文出自 “运维笔录 美玲” 博客,请务必保留此出处http://meiling.blog.51cto.com/6220221/1979320
使用nginx后让tomcat的localhost_access_log获得真实IP
标签:使用nginx后让tomcat的localhost_access_log获得真实ip tomcat的localhost_access_log获得真实ip
原文地址:http://meiling.blog.51cto.com/6220221/1979320