NAME

App::Cerberus::Plugin::GeoIP - Add geo-location information the user's IP address

VERSION

version 0.11

DESCRIPTION

This plugin uses the freely available GeoLite City database from MaxMind to add geo-location data to Cerberus.

For instance:

"geo": {
    "area_code": 201,
    "longitude": "-74.0781",
    "country_name": "United States",
    "region_name": "New Jersey",
    "country_code": "US",
    "region": "NJ",
    "city": "Jersey City",
    "postal_code": "07304",
    "latitude": "40.7167"
}

CONFIGURATION

To use this plugin, add this to your config file:

plugins:
  - GeoIP:    /opt/geoip/GeoLiteCity.dat

REQUEST PARAMS

Geo information is returned when an IPv4 address is passed in:

curl http://host:port/?ip=80.1.2.3

INSTALLING GEO::IP

To work properly, you should install the C API before installing Geo::IP. You can do this as follows: (I'm assuming you have write permissions on /opt):

wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz

tar -xzf GeoIP.tar.gz
cd GeoIP-*/

libtoolize -f
./configure --prefix=/opt/geoip
make && make check && make install

Then, find the latest version of Geo::IP from https://metacpan.org/release/Geo-IP and install it as follows:

wget http://cpan.metacpan.org/authors/id/B/BO/BORISZ/Geo-IP-1.40.tar.gz

tar -xzf Geo-IP-*
cd Geo-IP-*

perl Makefile.PL LIBS='-L/opt/geoip/lib64' INC='-I/opt/geoip/include'
# make && make test && make install
make && make install

Note: If you're installing GeoIP in a non-standard location (as above), then testing the Perl API won't work, because the path to the data file is hard coded. See https://rt.cpan.org/Public/Bug/Display.html?id=49531.

You will also need a copy of the GeoLite City database:

cd /opt/geoip
wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Clinton Gormley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.