To install GeoIP in cPanel server, run the following command as root,
root@server1 [~]# cd /var/cpanel/easy/apache/custom_opt_mods/
root@server1 [~]# wget http://docs.cpanel.net/twiki/pub/EasyApache3/CustomMods/custom_opt_mod-mod_geoip.tar.gz
root@server1 [~]# tar -zxf custom_opt_mod-mod_geoip.tar.gz
root@server1 [~]# /scripts/easyapache
Next compile it with easyapache,
root@server1 [~]# /scripts/easyapache
Then select the Mod_GeoIP in the Short Options List.
To block a certain country IP range, you do not need to know which IP range it is and what you need is to use the GeoIP feature.
Next, you will need to insert the following command to the .htaccess file,
Example
=========================================
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteRule ^(.*)$ http://www.google.com [L]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteRule ^(.*)$ http://www.google.com [L]
========================================
The command use to redirect China IP to google.com.
Ref: http://docs.cpanel.net/twiki/bin/view/EasyApache3/CustomMods
http://dev.maxmind.com/geoip/mod_geoip2
No comments:
Post a Comment