title: Nginx replace REMOTE_ADDR with X-Forwarded-For
body: <p>I am quite new to Nginx, and it seems all so confusing. I have my server setup perfectly, but the problem is, since my server is protected using a HTTP proxy; instead of logging the real users IP's, it's logging the proxy server IP.</p>
  
  <p>What I tried doing was setting <code>$_SERVER['REMOTE_ADDR'];</code> to <code>$_SERVER['X-Forwarded-For'];</code> but I'm getting a undefined index error, so I'm guessing I have to define <code>X-Forwarded-For</code> in Nginx? But I am not aware how to do so, I have a simple setup, it's just Nginx with PHP. Nothing more, nothing less.</p>
  
  <p>I've searched all over the web, but can't actually find some information that is friendly to understand. </p>
  
  <p>I have access to the source code, if that somewhat helps. I've tried many solutions, but to no avail. </p>