码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-11-25 23:45:14      阅读:448      评论: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
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!