Forward Headers not working in Spring Boot + Kubernetes
I figured it out. My mistake was assuming that networkCIDR
was the IP address returned by request.getRemoteAddr()
, when it was actually my k8s internal cluster IP. This makes sense given that the request is coming from Apache, which is also inside the cluster. The internal cluster IP was NOT in the list of internal proxies, and thus RemoteIPValve
was not utilizing the forward headers.
By adding the server.tomcat.internal-proxies
property to my application.properties
with the default values specified in RemoteIpValve
AND my internal cluster IP, everything worked as it should.