title: How do I safely get the user's real IP address in Flask (using mod_wsgi)?
body: <p>I have a flask app setup on mod_wsgi/Apache and need to log the IP Address of the user. request.remote_addr returns "127.0.0.1" and <a href="http://esd.io/blog/flask-apps-heroku-real-ip-spoofing.html">this fix</a> attempts to correct that but I've found that Django removed similar code for security reasons.</p>
  
  <p>Is there a better way to safely get the user's real IP address?</p>
  
  <p>EDIT: Maybe I'm missing something obvious. I applied <a href="https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/contrib/fixers.py#L94-144">werkzeug's/Flask's fix</a> but it doesn't seem to make a difference when I try a request with altered headers:</p>
  
  <p>run.py:</p>
  
  <pre><code>    from werkzeug.contrib.fixers import ProxyFix
      app.wsgi_app = ProxyFix(app.wsgi_app)
      app.run()
  </code></pre>
  
  <p>view.py:</p>
  
  <pre><code>for ip in request.access_route:
          print ip # prints "1.2.3.4" and "my.ip.address"
  </code></pre>
  
  <p>This same result happens if I have the ProxyFix enabled or not. I feel like I'm missing something completely obvious</p>