To install mod_remoteip in Cpanel Server, run
yum install ea-apache24-mod_remoteip
Edit file
vi /etc/apache2/conf.modules.d/370_mod_remoteip.conf
Add
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 127.0.0.1 PROXY_SERVER_IP_HERE
Restart Apache.
systemctl restart apache2
At this stage, PHP applications will show the proper visitor IP addresses.
Apache access logs will still show the proxy server IP. To fix this, edit the Apache configuration file.
Find
LogFormat "%h %l %u %t \"%r\" %>s %b" common LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
Replace with
LogFormat "%a %l %u %t \"%r\" %>s %b" common LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
Restart Apache
systemctl restart apache2
Cloudflare Restore Real IP Address in Cpanel Server
Back to Cpanel Server
Leave a Reply