How to get IP of client when request is proxied via HTTP Gateway ?
Issue
- We use this code to get the client ip in the jax-ws service.
Message message = PhaseInterceptorChain.getCurrentMessage();
HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
String remoteAddr = request.getRemoteAddr();
// Handle proxy
String header = request.getHeader( "x-forwarded-for" );
if( header != null && !header.isEmpty() ) {
remoteAddr = header.split( "," )[0];
}
- This works when we make the request the CXF endpoint in Fuse.
- But when the request is proxied through the http gateway - we get the ip address of the Gateway server.
- We need to get the ip address when request go through the Http gateway. Recommend a solution.
Environment
- Red Hat JBoss Fuse
- 6.2.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.