Allowing Apache to see client ip from Behind a trusted proxy.

With high speed caching based on nginx, varnish or CDNs in general the client ip gets lost. All
IPs get reported as since the proxy is making the socket request. Solution is two phased:

1) enable reporting the client IP to the X-Forwarded-For header at the proxy or CDN.

This depends on the proxy will be covered in separate posts.

2) installing and configuring the mod_remoteip in Apache 2.


Project link L
mkdir /usr/local/src/mod_remoteip
cd /usr/local/src/mod_remoteip

yum install httpd-devel
make install

Configuration in the Apache config file:

in /etc/httpd/conf/httpd.conf

# Load and configure mod_remoteip for Google PageSpeed Service
LoadModule remoteip_module /usr/lib64/httpd/modules/
RemoteIPHeader X-Forwarded-For

service apache reload

voila 🙂

Write a Reply or Comment

Your email address will not be published.