This is an apache moduke and is only capable of looking up the IP of a client that connects to the web server. Once this module is enabled, the configuration can be entered in .htaccess file. This has a database associated with it and the location of this is "/usr/local/share/GeoIP/GeoIP.dat".Some variables can be set depending on the variables set as below,
=-=-=-
GEOIP_CONTINENT_CODE, GEOIP_COUNTRY_CODE .....
=-=-=-
To redirect a client based on country, It can be achieved using the below rule,
-=-=-=-=-=
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat
# Redirect one country
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://www.canada.com$1 [R,L]
# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$
RewriteRule ^(.*)$ http://www.northamerica.com$1 [R,L]
=-=-=-=-=-=
To know more, refer the URL: http://dev.maxmind.com/geoip/legacy/mod_geoip2/
# cd /usr/local/src/
# wget -c http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz --> Geoip Database
# tar -xzf GeoIP-1.4.6.tar.gz
# cd GeoIP-1.4.6/
# ./configure
# make
# make install
# chown nobody.nobody /usr/local/share/GeoIP/GeoIP.dat
# echo '/usr/local/lib ' > /etc/ld.so.conf.d/geio.conf
# ldconfig
# cd /usr/local/src/
# wget -c http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz --> Mod_Geoip
# tar -xzf mod_geoip2_1.2.5.tar.gz
# cd mod_geoip2_1.2.5/
# /usr/local/apache/bin/apxs -lGeoIP -cia mod_geoip.c
Now, create a file /usr/local/apache/conf/geoip.conf and add below,
=-=-=-
LoadModule geoip_module modules/mod_geoip.so
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat MemoryCache
</IfModule>
=-=-=-
echo 'Include "/usr/local/apache/conf/geoip.conf" ' >> /usr/local/apache/conf/includes/pre_main_global.conf
Now, bebuild and restart apache using the below commands,
=-=-=-=-
# /scripts/rebuildhttpdconf
# /scripts/restartsrv httpd
=-=-=-=-
Done
=-=-=-
GEOIP_CONTINENT_CODE, GEOIP_COUNTRY_CODE .....
=-=-=-
To redirect a client based on country, It can be achieved using the below rule,
-=-=-=-=-=
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat
# Redirect one country
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://www.canada.com$1 [R,L]
# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$
RewriteRule ^(.*)$ http://www.northamerica.com$1 [R,L]
=-=-=-=-=-=
To know more, refer the URL: http://dev.maxmind.com/geoip/legacy/mod_geoip2/
# cd /usr/local/src/
# wget -c http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz --> Geoip Database
# tar -xzf GeoIP-1.4.6.tar.gz
# cd GeoIP-1.4.6/
# ./configure
# make
# make install
# chown nobody.nobody /usr/local/share/GeoIP/GeoIP.dat
# echo '/usr/local/lib ' > /etc/ld.so.conf.d/geio.conf
# ldconfig
# cd /usr/local/src/
# wget -c http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz --> Mod_Geoip
# tar -xzf mod_geoip2_1.2.5.tar.gz
# cd mod_geoip2_1.2.5/
# /usr/local/apache/bin/apxs -lGeoIP -cia mod_geoip.c
Now, create a file /usr/local/apache/conf/geoip.conf and add below,
=-=-=-
LoadModule geoip_module modules/mod_geoip.so
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/local/share/GeoIP/GeoIP.dat MemoryCache
</IfModule>
=-=-=-
echo 'Include "/usr/local/apache/conf/geoip.conf" ' >> /usr/local/apache/conf/includes/pre_main_global.conf
Now, bebuild and restart apache using the below commands,
=-=-=-=-
# /scripts/rebuildhttpdconf
# /scripts/restartsrv httpd
=-=-=-=-
Done