Block IPs by country – Apache



Step 1

If you are using debian or ubuntu, install the mod-geoip package.

sudo apt-get install libapache2-mod-geoip

 

Step 2
Enable GeoIPEnable, edit geoip.conf

 

Step 3
Find Country Code Lookup: https://en.wikipedia.org/wiki/ISO_3166-1

In Apache vhosts file, outside of the </Directory> tags:

Step 4
service apache2 restart