How to block countries using Geo IP

Web hosting, SEO, etc... related
Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

How to block countries using Geo IP

Post by Neo » Sat Feb 06, 2010 7:21 pm

You can use the GeoIP Apache API to block unwanted countries.

For example, the following Apache configuration directives uses GeoIP Country to block traffic from China and Russia.

Code: Select all

GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
# ... place more countries here

Deny from env=BlockCountry

# Optional - use if you want to allow a specific IP address from the country you denied
# (See http://httpd.apache.org/docs/1.3/mod/mod_access.html for more details)
Allow from 10.1.2.3
Post Reply

Return to “Web Related”