Spring Boot with embedded Tomcat behind Apache proxy

前端 未结 7 1385
暖寄归人
暖寄归人 2020-12-08 09:51

We have a Spring Boot (Spring MVC) app with embedded Tomcat on a dedicated appserver behind an Apache SSL proxy.

The SSL port on the proxy server is 4433, forwarding

7条回答
  •  我在风中等你
    2020-12-08 10:44

    Your proxy looks fine, and so does the backend app, up to a point, but it doesn't seem to be seeing the RemoteIpValve modified request. The default behaviour of the RemoteIpValve includes a pattern match for the proxy IP address (as a security check) and it only modifies requests that it thinks are from a valid proxy. The pattern defaults in Spring Boot to a well-known set of internal IP addresses like 10.*.*.* and 192.168.*.*, so if your proxy isn't on one of those you need to explicitly configure it, e.g.

    server.tomcat.internal-proxies=172\\.17\\.\\d{1,3}\\.\\d{1,3}|127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}
    

    (using properties file format, which means you have to double escape the backslashes).

    You can see the what is happening in the RemoteIpValve if you set

    logging.level.org.apache.catalina.valves.RemoteIpValve=DEBUG
    

    or set a breakpoint in it.

提交回复
热议问题