MaxMind GeoIP.js blocked on your site? Make your own GeoIP locator service

If you send too much traffic to MaxMind’s geo-IP location service, they will cut you off. Ok, maybe they just don’t like you. In fact, they’ll give you this warning/error:

<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
<html>

<head><title>302 Found</title></head>

<body>
<h1>Found</h1>
<p>The document has moved <a href=”http://j.maxmind.com:666//app/geoip.js”>here</a>.</p>
<hr>
<address>Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7a Server at www.maxmind.com Port 80</address>
</body>

</html>

Yes, gay indeed.

If you need their service, you might want to try implementing your own service with their downloadable database. They have several methods of quering the database. If you have linux knowledge, I highly recommend the Linux/Apache method (it’s super fast and super easy to install):

Here are steps, for people who are operating Ubuntu/Debian

1. Download the database as outlined here:

wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

2. Install the mod_ip for apache as outlined here:

apt-get install libapache2-mod-geoip

emacs vi /etc/apache2/mods-available/geoip.conf

(modify geoip.conf to this)

<IfModule mod_geoip.c>
  GeoIPEnable On
  GeoIPDBFile /path/to/your/GeoLiteCity.dat
</IfModule>

/etc/init.d/apache2 restart

Now you can query the IP location from your PHP like so:

<html>
<body>
<?php
$country_code = apache_note(“GEOIP_COUNTRY_CODE”);
$region = apache_note(“GEOIP_REGION”);
$city = apache_note(“GEOIP_CITY”);

echo $city. “, “. $region;
?>
</body>
</html>

Voila!

Related posts:

  1. Dos Shell Scripting for Newbies
Leave a comment

1 Comments.

  1. Bohuslav Jonathan Tóth

    hi there im working on something like this and i cant get it work properly.

    1. main server is located in london, using geoip to get continet code to show of a visitor connecting to web server. there are several web domains connecting to it as http and www as well

    2. i want to incoming header and address using continent geoip code forward it to another reverse proxy located in another continent using geoip. reverse proxy has already a database of running web addresses and where to looking for files on original web server

    3. i just do not know how to use header coming to main server and forward it to reverse proxy so reverse proxy would see it as coming straight to it. main server should not have a database of running web sites. just a plain redirection using geoip to reverse proxy on another continet

    i know this shouldbe easy i just need help

    thanx, john

Leave a Reply

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

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>