gpt4 book ai didi

tomcat - 无法在 Tomcat 8.0 访问日志中检索 X-Forwarded-For

转载 作者:行者123 更新时间:2023-11-28 23:25:53 25 4
gpt4 key购买 nike

我在我的 LB 上注入(inject)一个带有重写策略的 header 以传递 X-Forwarded-For header 。已验证这出现在 RESPONSE header 中的所有页面上。

我在 server.xml 中有以下配置,但我无法使用 %a 或 %h(我看到 Loadbalancer IP)看到远程 IP/X-Forwarded-For

可能是什么问题?

            <Valve className="org.apache.catalina.valves.RemoteIpValve"
internalProxies="10\.202\.13\.198"
remoteIpHeader="X-Forwarded-For"
proxiesHeader="x-forwarded-by"
requestAttributesEnabled="true"
/>
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="localhost_access_log"
suffix=".txt"
pattern="%t %a %h %{Referer}i %l %S %{User-Agent}i %U %s %r %q %A %v %p %b %I %D"
requestAttributeEnabled="true"
resolveHosts="false"/>

日志::

[11/May/2016:11:29:39 -0700] 10.202.13.198 10.202.13.198 https:///index.action - 04B3ADCF82A212C6ECD9679BF260732D Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWeb套件/537.36 ( KHTML,像 Gecko) Chrome/50.0.2661.86 Safari/537.36/rest/mywork/latest/status/notification/count 200 GET/rest/mywork/latest/status/notification/count HTTP/1.1 10.202.10.17 443 72 http-nio -8443-exec-17 13

如您所见:%a 和 %h 都是:10.202.13.198 10.202.13.198(我的 LB IP)

最佳答案

看起来正在检查 REQUEST header 。在请求 header 中注入(inject) X-Forwarded-For 后,%a 和 %h 都显示了我的远程地址。另外,请注意 X-Forwarded-For 不区分大小写。

关于tomcat - 无法在 Tomcat 8.0 访问日志中检索 X-Forwarded-For,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37170742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com