To enable Geo-IP Blocking on Debian 9 Stretch, assuming you already have a running Apache web server:
- apt install libmaxminddb0 libmaxminddb-dev
- apt install apache2-dev
- Download and extract the latest MaxMind Apache mod version from:
https://github.com/maxmind/mod_maxminddb/releases - Follow the instructions to configure and install from the source code
- Download and install the GeoIP Update program to automate downloads of the database:
https://github.com/maxmind/geoipupdate/releases - 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