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

作者:Mr.Ares
出处:http://www.cnblogs.com/aresxin/
个性签名:许多人的付出都是浅尝辄止!
  • 相关阅读:
    thinkphp自动映射分析
    thinkphp自动创建数据对象分析
    html模板输头部出现"&#65279"
    register_shutdown_function 函数详解
    mcrypt加密以及解密过程
    SVN不能解锁,报错:没有匹配的可用锁令牌的解决方法
    微信公众平台JSSDK开发
    PHP的UTF-8中文转拼音处理类
    PHP中文转拼音函数
    php生成mysql数据字典
  • 原文地址:https://www.cnblogs.com/aresxin/p/4996248.html
  • Copyright © 2020-2023  润新知