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-IPCountryheader, and its firewall rules can block or allow countries before traffic reaches your server. - On your own server: the
mod_maxminddbApache module reads GeoLite2 databases. It is not packaged for cPanel, so install it only on servers without cPanel (build it withapxsfrom 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.