IT Certificaions

Google Cloud Platform

Wednesday, December 21, 2011

Get real client ip-address using java / getRemoteAddr() is giving 127.0.0.1 as client ip address in java


Getting real client ip-address using java (if Apache redirection is used...)
--------------------------------------------------------------------------
You can use ,
    String ipAddress=request.getHeader("X-Forwarded-For");
 if you have configured Apache redirection.
-------------------------------------------------------------------------

If you will use
     request.getRemoteAddr(), it may return 127.0.0.1 if apache redirection has been configured at your deployment server.