Plack::Middleware::GeoIP2 - Find country and city of origin of a web request
# 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' ];
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
When REMOTE_ADDR is an invalid/unknown IP, this module will set 'ZZ', 'Unknown Country', and 'Unknown Continent' for the above variables.
GeoIPDBFile => '/path/to/GeoIP.dat' GeoIPDBFile => [ '/path/to/GeoIP.dat', '/path/to/GeoIPCity.dat' ]
Path to GeoIP2 data files.
GeoIP2Locales => [ 'en', 'de' ]
Array of locale names passed to GeoIP2, to localize GEOIP_COUNTRY_NAME.
Zak B. Elep <zakame@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
mod_geoip
GeoIP2
To install Plack::Middleware::GeoIP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::GeoIP
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::GeoIP
For more information on module installation, please visit the detailed CPAN module installation guide.