NAME

Plack::Middleware::GeoIP2 - Find country and city of origin of a web request

SYNOPSIS

# with Plack::Middleware::RealIP
enable 'Plack::Middleware::RealIP',
    header => 'X-Forwarded-For',
    trusted_proxy => [ qw(192.168.1.0/24 192.168.2.1) ];
enable 'Plack::Middleware::GeoIP',
    GeoIP2DBFile => [ '/path/to/GeoLite2-Country.mmdb', '/path/to/GeoIP2-Country.mmdb' ];

DESCRIPTION

Plack::Middleware::GeoIP2 is a version of Plack::Middleware::GeoIP using the more recent GeoIP2 library from MaxMind.

All requests are looked up and GEOIP_* variables are added to PSGI environment hash. For improved performance, you may want to only enable this middleware for specific URL's.

The following PSGI environment variables are set by this middleware:

GeoIP Country Edition:

GEOIP_COUNTRY_CODE, GEOIP_COUNTRY_NAME, GEOIP_CONTINENT_CODE

CONFIGURATION

GeoIPDBFile
GeoIPDBFile => '/path/to/GeoIP.dat'
GeoIPDBFile => [ '/path/to/GeoIP.dat', '/path/to/GeoIPCity.dat' ]

Path to GeoIP2 data files.

GeoIP2Locales
GeoIP2Locales => [ 'en', 'de' ]

Array of locale names passed to GeoIP2, to localize GEOIP_COUNTRY_NAME.

AUTHOR

Zak B. Elep <zakame@cpan.org>

LICENSE

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

SEE ALSO

mod_geoip

GeoIP2