restlet-framework-java icon indicating copy to clipboard operation
restlet-framework-java copied to clipboard

ClientInfo.getUpstreamAddress() does not return IP as set in X-Forwarded-For header

Open ebner opened this issue 6 years ago • 2 comments

The application is executed in Tomcat 8 using the Servlet connector, behind an Apache HTTPD which is configured as reverse proxy. The reverse proxy sets the X-Forwarded-For header correctly, but the method request.getClientInfo().getUpstreamAddress() returns the IP of the proxy, and not the IP as specified by X-Forwarded-For.

The header can be accessed directly using request.getHeaders().getFirstValue("x-forwarded-for", true) on the very same request, so something seems to be broken in the convenience method ClientInfo.getUpstreamAddress().

I am calling getContext().getParameters().add("useForwardedForHeader", "true") in the Restlet's createInboundRoot() method, I don't know whether that's needed for the Servlet connector though.

The Restlet version in use is 2.3.12 on OpenJDK 1.8.0_191.

ebner avatar Mar 10 '19 20:03 ebner

@ebner you may be interested in joining the "Unofficial Restlet Community" https://gitter.im/restlet-framework/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link

cyberquarks avatar Mar 25 '21 14:03 cyberquarks

@jlouvel Here's the block

flatlanderer avatar Mar 25 '21 14:03 flatlanderer

In Restlet 3.0 we will be dropping support for Servlet to focus on deployment to cloud native architectures, microservices, service mesh, reducing the value of Servlet containers.

jlouvel avatar Jan 23 '25 03:01 jlouvel