首页 > Web开发 > 详细

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

时间:2015-11-25 23:42:52      阅读:475      评论:0      收藏:0      [点我收藏+]

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

    Apche配置:

    <IfModule log_config_module>

        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

        <IfModule logio_module>

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

        </IfModule>

        CustomLog "logs/access_log" common

    </IfModule>

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

    原文:http://www.cnblogs.com/aresxin/p/4996248.html

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
    © 2014 bubuko.com 版权所有
    打开技术之扣,分享程序人生!