Home Software Consultant

Django Lessons - #2

2010-09-07T17:17:04+00:00

I needed to record the IP address of the user as well as the admin for every action completed. And, this IP must show with each log entry. So, I used user_ip=request.META["REMOTE_ADDR"]). But, this did not work on the server. The IP was getting recorded as 127.0.0.1. Why so? The information I got from the webfaction support was that

REMOTE_ADDR is 127.0.0.1 because requests for your site are proxied through our front-end web server, which of course is on the local host.If you want the original IP of the request, then use request.META['HTTP_X_FORWARDED_FOR'].

I did some research, and found about the concept of reverse proxy. Some linksForumApache