Install GeoIP Apache Module in CentOS

To install GeoIP Apache module on CentOS 7, run

yum -y install GeoIP GeoIP-devel GeoIP-data
yum -y install mod_geoip 

Now you need to configure Apache VirtualHost.

To block traffic, add following to your VirtualHost entry

RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CN|RU|A1)$
RewriteRule ^(.*)$ https://serverok.in [L]

In this example, traffic from CN, RU and A1 (stands for proxy IP) get redirected to specified URL.

geoip

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *