【问题标题】:Tomcats RemoteIPValve not invoked in Spring Boot Application deployed as a WAR fileTomcats RemoteIPValve 未在部署为 WAR 文件的 Spring Boot 应用程序中调用
【发布时间】:2016-01-29 18:02:09
【问题描述】:

我的 Spring Boot 1.3.2 应用程序作为 WAR 文件部署到独立的 tomcat7 中。我正在尝试使用server.use-forward-headers=true 激活 RemoteIPValve,如spring boot docs 中所述。

但是在处理请求时,RemoteIPValve 没有正确配置或调用。日志说:

检测到 NonEmbeddedServletContainerFactory。

当我使用 maven 插件启动应用程序时,我得到一个:

初始化 Spring 嵌入式 WebApplicationContext

... RemoteIPValve 正在按预期工作。如何使用 WAR 文件部署来完成同样的任务?

【问题讨论】:

    标签: spring tomcat spring-boot embedded-tomcat-7


    【解决方案1】:

    当您将 Spring Boot 应用程序部署到独立 Tomcat 时,嵌入式服务器配置都不会生效。相反,您需要更新 Tomcat 安装的配置以启用阀门。要在默认配置中使用阀门,请将以下内容添加到 server.xml

    <Valve className="org.apache.catalina.valves.RemoteIpValve"/>
    

    【讨论】:

      猜你喜欢
      • 2019-07-07
      • 2021-12-28
      • 1970-01-01
      • 2018-12-08
      • 2020-03-05
      • 2015-04-18
      • 2023-02-01
      • 2015-09-03
      • 2016-05-04
      相关资源
      最近更新 更多