haproxy,tomcat.apache记录用户真实IP

Haproxy配置:

default加入:

option httpclose

option forwardfor

Tomcat配置:

server.xml中添加

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"/>完整配置为:

                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"/>

Apche配置:

    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common

   

      LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

   

    CustomLog "logs/access_log" common

转载于:https://www.cnblogs.com/aresxin/p/4996248.html

你可能感兴趣的:(haproxy,tomcat.apache记录用户真实IP)