Install mod_remoteip in Cpanel Server
To install mod_remoteip in Cpanel Server, run
1 |
yum install ea-apache24-mod_remoteip |
Edit file
1 |
vi /etc/apache2/conf.modules.d/370_mod_remoteip.conf |
Add
1 2 |
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 127.0.0.1 PROXY_SERVER_IP_HERE |
Restart Apache.
1 |
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
1 2 |
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
1 2 |
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
1 |
systemctl restart apache2 |
Cloudflare Restore Real IP Address in Cpanel Server
Back to Cpanel Server