1. 首先在阿里云的SLB的配置上开启X-Forwarded-For 

    wKioL1h11uuDVa84AAB-_nt7RCY508.png-wh_50

  2. 在后端的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 &quot;%r&quot; %s %b" />