Updated: 28 September 2026 · Applies to: cPanel & WHM 138 and Apache 2.4

mod_geoip used the legacy GeoIP databases, which are discontinued, and it is not part of EasyApache 4 on current cPanel servers. For country-based rules in Apache, use one of these approaches instead:

  • In your application: read the visitor's country with MaxMind's GeoLite2 database and PHP library (see "How to Install the PHP GeoIP Extension?"). This works on any hosting.
  • Behind Cloudflare: Cloudflare adds the visitor's country in the CF-IPCountry header, and its firewall rules can block or allow countries before traffic reaches your server.
  • On your own server: the mod_maxminddb Apache module reads GeoLite2 databases. It is not packaged for cPanel, so install it only on servers without cPanel (build it with apxs from its source release).

Example: block a country in .htaccess with Cloudflare

RewriteEngine On
RewriteCond %{HTTP:CF-IPCountry} ^(XX|YY)$
RewriteRule ^ - [F]

Replace XX|YY with two-letter country codes. The header can be faked by visitors who reach your server directly, so combine it with a firewall that only allows Cloudflare's addresses if you rely on it.

Related services

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

cPanel server management

hardening, migrations and 24/7 monitoring, with no long-term contract.

cPanel, Plesk and LiteSpeed licences

for VPS and dedicated servers, with installation help on demand.

Was this answer helpful?

Still stuck? Open a ticket