title: How to get the first client ip from X-Forwarded-For behind nginx + Gunicorn?
body: <p>Deploy a flask app with nginx + Gunicorn, and I need to get the real ip from visitors. (for Gunicorn can not get REMOTE-ADDR after nginx) I try to get client ip from X-Forwarede-for by this:</p>
  
  <p><strong>client_ip = request.headers.getlist("X-Forwarded-For")[0]</strong></p>
  
  <p>Sometimes I get client_ip correctly like this:</p>
  
  <blockquote>
    <p>x-forwarded-for: 62.211.19.218</p>
  </blockquote>
  
  <p>But sometimes I get client_ip wrong like this - combined with a proxy ip address (visit from some different Browsers):</p>
  
  <blockquote>
    <p>x-forwarded-for: 62.211.19.218, 177.168.159.85</p>
  </blockquote>
  
  <p>How to get only the first client ip (without the proxy address 177.168.159.85) when nginx forwards two ip addresses to App?</p>