Obtaining the connecting clients IP address (Real IP) with cPanel
cPanel is a Linux based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides capabilities for administrators, resellers, and end-user website owners to control the various aspects of website and server administration through a standard web browser.
cPanel Method (Apache/httpd):
cPanel uses Apache which allows you to use the mod_rpaf module, all that is required is for the module to be installed and enabled in cPanel.
Login to your server using the Secure Shell (SSH) credentials provided to you and enter the below mentioned commands to install mod_rpaf on a cPanel Server.
Run the commands below to download mod_rpaf and install it alongside Apache.
cd /usr/local/src wget http://mirror.trouble-free.net/sources/mod_rpaf-0.6.tar.gz tar -xzf mod_rpaf-0.6.tar.gz cd mod_rpaf-* apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
First login to WHM as administrator
Once installed, we need to load the module into Apache configuration. Since cPanel already has Include Editor for Apache, we will use that function.
Service Configuration > Apache Configuration > Include Editor > Pre Main Include > All Versionsand paste following text:
LoadModule rpaf_module modules/mod_rpaf-2.0.so RPAFenable On RPAFproxy_ips 127.0.0.1 188.8.131.52 RPAFsethostname On RPAFheader X-Real-IP
Where 184.108.40.206 is your proxy IP.
Update > Restart Apache. The module should be loaded after restart.
To ensure that cPanel will remember that Apache configuration template has changed we need to run the following commands:
/usr/local/cpanel/bin/apache_conf_distiller --update --main /scripts/rebuildhttpdconf
More information on the X-Real-IP header can be found here. More information on cPanel can be found on their website cPanel. More information on the Apache (httpd) web server can be found on the project website and documentation for the mod_rpaf module.