【发布时间】:2016-05-11 18:33:01
【问题描述】:
我在我的 LB 上注入一个带有重写策略的标头以传递 X-Forwarded-For 标头。已验证这出现在响应标题中的所有页面上。
我在 server.xml 中有以下配置,但我无法使用 %a 或 %h 看到远程 IP/X-Forwarded-For(我看到负载平衡器 IP)
可能是什么问题?
<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;英特尔 Mac OS X 10_11_4)AppleWebKit/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)
【问题讨论】:
标签: tomcat