mod_remoteip replaces the original client IP address for the connection with the UserAgent IP address. It is very useful if Apache is running behind a proxy. Please check out the steps to Install mod_remoteip on cPanel below.
If your cPanel server using EasyApache 3, please follow the steps below:
cd /var/cpanel/easy/apache/custom_opt_mods wget https://documentation.cpanel.net/download/attachments/2326651/custom_opt_mod-remoteip.tgz tar -xvf custom_opt_mod-remoteip.tgz rm -f custom_opt_mod-remoteip.tgz
Rebuild Apache using EasyApache. You can find the mod_remoteip module is listed on the “Exhaustive Options List“. Also, please note that Apache 2.4 is needed to install mod_remoteip
If your cPanel server using EasyApache 4, please follow the step below:
yum install ea-apache24-mod_remoteip
Common steps to follow after installing mod_remoteip:
Once the EasyApache Build is completed, you can verify the installation using the following command.
httpd -M | grep remoteip
root@server [~]# httpd -M | grep remoteip remoteip_module (shared) root@server [~]#
Add the following configuration in mod_remoteip.conf
RemoteIPHeader X-Real-IP RemoteIPInternalProxy SERVER_IP_ADDRESS
Replace the SERVER_IP_ADDRESS with your server IP address. Also, you can try the following configuration to correct the client’s IP address passing to PHP.
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 127.0.0.1 SERVER_IP_ADDRESS
# VERSION 0.1 LoadModule remoteip_module modules/mod_remoteip.so <IfModule remoteip_module> # These settings are specific to your environment, so # we'll leave them commented out until you manually set # them. I recommend carefully reading the documentation # as misconfiguration of this module can result in # potential data compromise. # # https://httpd.apache.org/docs/trunk/mod/mod_remoteip.html # --------------------------------------------------------- RemoteIPHeader X-Real-IP RemoteIPInternalProxy 188.8.131.52 # RemoteIPProxiesHeader X-Forwarded-By # RemoteIPTrustedProxy proxy.example.com # RemoteIPTrustedProxyList conf/trusted-proxies.lst </IfModule>
Restart the Apache.