首先在阿里云的SLB的配置上开启X-Forwarded-For
在后端的tomcat配置文件conf/server.xml中添加%{X-Forwarded-For}i
结果如下:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%{X-Forwarded-For}i %h %l %u %t "%r" %s %b" />
转载于:https://blog.51cto.com/wangqh/1891070