Java, the IP address and reverse proxy

Okay so there is the getRemoteAddr() method of HttpServletRequest, but when you’re using a reverse proxy that won’t work and it will just return 127.0.0.1

If so, look for the header ‘X-Forwarded-For‘ of your request object. (request.getHeader("X-Forwarded-For")).
But this will return null if using non-reverse proxy. ;)

thanks to POLONKAI Gergely

SPEAK / ADD YOUR COMMENT
Comments are moderated.

You must be logged in to post a comment.

Return to Top