Why request.getRemoteAddr (). Equals ("127.0.0.1") when accessing from a remote computer

I have a Java servlet application running in Tomcat, there is one admin command that I only want to be able to run from the machine itself (or perhaps my own computer) for security reasons. Therefore, to ensure this, I check the remote HttpServletRequest address that I receive, but it always returns 127.0.0.1, even if the request does not come from the local host

Why can I fix this or is there an alternative way to run my admin command only from the server.

+5
source share
1 answer

, "X-Forwarded-For". , IP- , . , request.getRemoteAddr() IP-.

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

, 100% , IP, , "X-Forwarded-For".

+3

All Articles