Mod maxminddb » History » Revision 3
« Previous |
Revision 3/4
(diff)
| Next »
gstrauss, 2023-02-25 06:38
IP Based Geographic Lookups¶
- Table of contents
- IP Based Geographic Lookups
Module: mod_maxminddb
Requirements¶
Packages: GeoIP2 C API & Library libmaxminddb
https://github.com/maxmind/libmaxminddb
https://dev.maxmind.com/geoip/
https://dev.maxmind.com/geoip/geoip2/geolite2/
Overview¶
mod_maxminddb is a module for fast ip/location lookups, available since lighttpd 1.4.54. It uses MaxMind GeoIP2 databases. If the IP was found in the database, the module sets the appropriate environment variables to the request, thus making this information available to other modules/fcgi.
https://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads
mod_maxminddb consumes MaxMind GeoIP2 databases. This is the successor to GeoIP Legacy databases. GeoIP Legacy databases were discontinued 2 Jan 2019 (https://dev.maxmind.com/geoip/legacy/release-notes/) and mod_geoip is now deprecated.
Note: mod_maxminddb before lighttpd 1.4.70 expects a single client per connection and caches the geoip database lookup per-connection; mod_maxminddb before lighttpd 1.4.70 does not expect the IP to change between requests on the same connection. In lighttpd 1.4.70 and later, mod_maxminddb can be used with mod_extforward serving HTTP/1.1 connections from a load balancer configured to reuse connections for multiple clients. Before lighttpd 1.4.70, or with HTTP/2, mod_maxminddb should be used with load balancers configured to be safe, reusing a connection only for the same client, not for different clients. Alternatively, mod_magnet can be used instead of mod_extforward and mod_maxminddb, and a lua script can parse the X-Forwarded-For or other request header, and then query maxminddb.
Configuration Options¶
maxminddb.activate = "enable" (default: "disable")
maxminddb.db = "/path/to/the/GeoIP2/database.mmdb"
maxminddb.env = (...) - list of environment variables to set and associated lookup keys in GeoIP2 .mmdb.
maxminddb.env = (
"GEOIP_COUNTRY_CODE" => "country/iso_code",
"GEOIP_COUNTRY_NAME" => "country/names/en",
"GEOIP_CITY_NAME" => "city/names/en",
"GEOIP_CITY_LATITUDE" => "location/latitude",
"GEOIP_CITY_LONGITUDE" => "location/longitude",
)
Redirecting based on GeoIP2 data can be performed inside lighttpd using mod_magnet or using backend CGI, FastCGI, SCGI, etc.
Updated by gstrauss over 1 year ago · 3 revisions