I have a website set up with nginx acting as a reverse proxy to apache 2.2, which is running php. From apache and php's perspective the IP address of all requests is the nginx server. I'd like php to see the same remote IP that nginx sees.
Nginx sets a header X-Real-IP which contains the remote IP that nginx sees. I tried doing something like this in the apache conf:
SetEnvIf ^X-Real-IP$ "(.+)" REMOTE_ADDR=$1
My hope was that I could set the REMOTE_ADDR environment variable and when php finally gets invoked, it would see the remote IP that nginx sees. I think the php code is doing this:
$_SERVER['REMOTE_ADDR']
Anyway, this isn't working. Any ideas? Can you not set REMOTE_ADDR in the apache config file? Thanks.