Configure Geo-blocking with Apache on Debian

To enable Geo-IP Blocking on Debian 9 Stretch, assuming you already have a running Apache web server:

  1. apt install libmaxminddb0 libmaxminddb-dev
  2. apt install apache2-dev
  3. Download and extract the latest MaxMind Apache mod version from:
  4. Follow the instructions to configure and install from the source code
  5. Download and install the GeoIP Update program to automate downloads of the database:
  6. Enable the Apache module for your Virtualhost:
MaxMindDBEnable On
MaxMindDBFile DB /usr/local/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
  • Configure the countries to block within a Location/Directory stanza:
SetEnvIf MM_COUNTRY_CODE ^(RU|DE|FR) BlockCountry
Deny from env=BlockCountry