springtomcatspring-bootembedded-tomcat-7

Tomcats RemoteIPValve not invoked in Spring Boot Application deployed as a WAR file


My Spring Boot 1.3.2 Application is deployed as a WAR file into a standalone tomcat7. I am trying to activate the RemoteIPValve using server.use-forward-headers=true as described in the spring boot docs.

But the RemoteIPValve is not properly configured nor invoked when handling the request. Log says:

NonEmbeddedServletContainerFactory detected.

When I start the application using the maven plugin I get a:

Initializing Spring embedded WebApplicationContext

... and RemoteIPValve is working as expected. How can I accomplish the same using WAR File deployment?


Solution

  • When you deploy a Spring Boot application to standalone Tomcat, none of the embedded server configuration takes effect. Instead, you need to update your Tomcat installation's configuration to enable the valve. To use the valve in its default configuration, add the following to server.xml:

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