So you're trying to track your users IP for one reason or another, but a glimpse at the REMOTE_ADDR server variable always returns localhost or 127.0.0.1.

Chances are, the reason this is happening is because your application server is running behind a web server such as Apache or IIS (as such is the case with Zope and other servers).

Because the application server is being forwarded requests from your web server, the REMOTE_ADDR variable will contain the localhost IP of 127.0.0.1.

Often times, these application servers offer another variable called HTTP_X_FORWARDED_FOR or similar. Try reading this variable instead, to see it is available and in fact carries the actual remote user's IP address.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *