How to get the IP address of the request to a Heroku app?
<p>Heroku has a routing system to forward requests to the dynos. My application needs to know from where the request came, but it always gets random addresses in a network, probably Heroku's internals.</p>

<p>And I see that in the logs, it (Heroku's router) gets my IP address and forwards the request. Is there a way to get the actual IP address of a request?</p>

<p>My application is written in Python, using Flask</p>

<p>Checking Flask's documentation on filtering headers etc., I found that:</p>

<pre><code>request.headers['X-Forwarded-For']
</code></pre>

<p>is where you'll get the client's real IP address.</p>

<hr>

<p>From a deleted comment by OP, this article provides a <a href="http://esd.io/blog/flask-apps-heroku-real-ip-spoofing.html" rel="nofollow">safer solution</a>.</p>

python heroku flask ip-address