1

This should be a common requirement. Please suggest.

My service runs behind a proxy which receives http request from the client and forwards it to one of the many available servers .

Now I want to log the identity (ip address and hostname) of the caller. But the issue is that since I get the request from the proxy, I happen to get proxy details (and not the callers). when I do a request.getRemoteAddr(); and subsequently InetAddress.getByName(ip).getHostName()

Is there a way to achieve this ?

Nrj
  • 6,723
  • 7
  • 46
  • 58

2 Answers2

3

Reverse proxies will typically use the 'X-Forwarded-For' header to identify the originating browser:

http://en.wikipedia.org/wiki/X-Forwarded-For

Missaka Wijekoon
  • 883
  • 7
  • 10
1

I assume you mean a reverse proxy. Some reverse proxies will set additional request headers indicating details about the client. You can either try looking at the headers you're getting to see if anything jumps out, or check the documentation for your proxy.

Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299