#1 By: mwolff, December 13th, 2013 14:07
I'm new to Heroku and when someone sends me a message on my site, I'd also like to collect the IP address of the person who did it.
I noticed that
request.META.get('REMOTE_ADDR') yields IP addresses that display as reserved like http://freegeoip.net/?q=10.6.130.86&map=1
I think I'm missing something that is a no-brainer. How can I collect the actual IP address of the person that made the POST request of my little contact form?
Super thanks in advance,
#2 By: hielke, December 10th, 2014 06:13
This question is pretty old, but an answer might still help people:
From Jacob, Heroku's Director of Security:
The router doesn't overwrite X-Forwarded-For, but it does guarantee that the real origin will always be the last item in the list.
This means that, if you access a Heroku app in the normal way, you will just see your IP address in the X-Forwareded-For header. I don't know for Django, but with Flask you can use request.access_route to get a list of ip-addresses (the full route) of which the first entry in the list should be the client's IP. So something like this:
provided_ips = request.access_route
# First entry in the list is the client's IP