For Techs.... Techniques.... Technologies....


How to install mod_remoteip for apache2.4 in Cpanel server

The latest version of apache (2.4) needs the module mod_remoteip for getting the clients real ipaddress in reverse proxy setups. We could not follow the conventional method of custom module installation in the latest Cpanel as it will not work any more.

This tutorial explains the detailed steps to install and configure mod_remoteip in latest version of Cpanel server have easyapache4 by default.

Step1: Login to the server via SSH

Step2: Install the module mod_remoteip for apache24

#yum install ea-apache24-mod_remoteip

Step3: Open the configuration file "/etc/apache2/conf.modules.d/360_mod_remoteip.conf" and update the below lines. Please note, you need to replace the 'server-ipaddress' with the front-end server ipaddress.

# Enable mod_remoteip
LoadModule remoteip_module modules/
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy server-ipaddress

Step4: Note that the client's ipaddress passing to PHP will be correct now. But Apache continues to log the reverse proxy server ipaddress as the client ipaddress in domains access log. So We need to correct the log format in apache configuration. Update the lines,

LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined


LogFormat "%a %l %u %t \"%r\" %>s %b" common
LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

Step5: Restart apache service

#/etc/init.d/httpd restart

That's all.........


Leave a Reply