Obtaining the client IP address with cPanel

cPanel is a Linux hosting control panel with interfaces for administrators, resellers and website owners.

For cPanel servers using EasyApache 4 and Apache 2.4, use mod_remoteip to process the client address supplied by X4B. Current cPanel installations include this module with Apache; do not build the old mod_rpaf module from a downloaded archive.

Configure Apache through WHM

  1. Confirm that the server uses EasyApache 4 and that remoteip_module is loaded, for example with apachectl -M as the server administrator.
  2. Check whether cPanel's NGINX integration or another local proxy already manages real-IP configuration. If it does, follow that integration's configuration method and identify every trusted hop before adding another rule.
  3. For Apache receiving traffic directly from X4B, open WHM → Service Configuration → Apache Configuration → Include Editor. For a global configuration, select Pre Main Include → All Versions. This affects every virtual host; use cPanel's supported per-virtual-host includes if only selected sites are proxied.
  4. Add the following directives, replacing the example address with each current X4B backend communication address:
RemoteIPHeader X-Real-IP
RemoteIPTrustedProxy 192.0.2.10

192.0.2.10 is an example, not an X4B address. Add one RemoteIPTrustedProxy directive per trusted source. If you changed Backend Real IP Header in HTTP Options, use that header name instead.

Do not add a second LoadModule line or edit the generated httpd.conf directly. cPanel can overwrite unsupported configuration changes.

Validate the result

  1. Save the include with Update, check the Apache configuration with apachectl -t, then restart Apache through WHM after the check succeeds. Include Editor preserves the configuration across cPanel rebuilds.
  2. Send a request through the protected hostname. Confirm that the application and access log show the visitor address.
  3. Confirm that a request from an untrusted connection cannot replace the client address by supplying a forged header. If direct connections are blocked, preserve that restriction.
  4. Recheck the configuration after changing the service's backend communication addresses or local proxy setup.

See the Apache guide for logging details, cPanel's supported configuration methods and cPanel NGINX integration.