让后端tomcat日志获取真实的IP,而不是nginx 服务器的IP

nginx nginx.conf中加
proxy_set_header X-Forwarded-For $remote_addr;
tomcat server.xml中加
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%{X-FORWARDED-FOR}i %l %u %t %r %s %b %D %q %{User-Agent}i %T" resolveHosts="false"/>

猜你喜欢

转载自blog.csdn.net/slovyz/article/details/53813824