【发布时间】:2018-08-23 16:26:25
【问题描述】:
我在 web.xml 中设置 RemoteIpFilter 时遇到问题:我在 web.xml 中放置了以下设置:
<filter>
<filter-name>RemoteIpFilter</filter-name>
<filter-class>org.apache.catalina.filters.RemoteIpFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RemoteIpFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
当我使用 HTTPS 标头向服务器发送请求时,没有“安全”标志。
但是如果我把
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="x-forwarded-for"
protocolHeader="x-forwarded-proto"
protocolHeaderHttpsValue="https" />
在 server.xml 中,同样的请求,我得到了“安全”标志。
我们更喜欢在 web.xml 中为每个应用程序设置配置。不知道为什么它在 web.xml 中不起作用 - 我按照 tomcat 配置文档 https://tomcat.apache.org/tomcat-8.5-doc/config/filter.html#Basic_configuration_to_handle_'x-forwarded-for'and'x-forwarded-proto 中的指示设置它p>
有人知道吗?提前致谢。
【问题讨论】:
标签: tomcat tomcat8 web.xml server.xml