SetEnv REMOTE ADDR if x-for-forwarded is present

Drixson Oseña asked:

I can translate this in PHP.. but I am curious if it’s possible to write this in on .conf file.. background of the setup. We have an ELB behind ec2 on AWS. We found out that REMOTE_ADDR is giving us the ELB ip address and not the client. So we want to fix this. 2 options 1.) in PHP or 2.) If can write in apache..

Can any give me an idea to write the snippet.

Thanks in advance

My answer:


For Apache 2.4+ you can use the built in mod_remoteip module to do the substitution automatically, which should already be included with your Linux distribution.

For Apache 2.2 you can use a mod_remoteip backport to do this substitution, or you can use the third party mod_rpaf module, which may already be included with your Linux distribution.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.