When getting the IP with request.META['REMOTE_ADDR']
code. This works fine on the local system but when hosted on a web server the ip got is 127.0.0.1 - How can this be resolved?
Your web server is probably behind a load balancer. You can try using request.META['HTTP_X_FORWARDED_FOR'].
Or better, look at the django book, chapter 15 - What’s Middleware? and Reverse Proxy Support (X-Forwarded-For Middleware) sections.
If you are behind a proxy and running apache as the webserver you could use mod_rpaf. The proxy only needs to send X-Forwarded-For or X-Real-IP headers.
http://stderr.net/apache/rpaf/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With