Document updated on Jan 28, 2021
GeoIP integration
The GeoIP integration allows you load Maxmind’s GeoIP2 City database (both commercial and free versions) and enrich all KrakenD calls to your backends with geo data.
To add GeoIP information to your backends, copy the Maxmind’s database file into the filesystem (it has to be a city DB) and specify its location in the configuration. Downloading the database requires signing up to MaxMind’s website.
Download the commercial or free GeoIP2 City
Configuration for GeoIP
Add the following extra_config
in the root to your configuration file:
{
"version": 3,
"plugin": {
"pattern":".so",
"folder": "/opt/krakend/plugins/"
},
"extra_config": {
"plugin/http-server": {
"name": ["geoip", "another-plugin-maybe" ],
"geoip": {
"citydb_path": "/etc/krakend/GeoIP2-City.mmdb"
}
}
}
}
citydb_path
: The path in the filesystem containing the database in GeoIP2 Binary (.mmdb
) format. Relative to the working dir or absolute path.
Data passed to backends
When the GeoIP plugin is enabled, all requests to the backend are enriched with a header X-GeoIP
.
The following metadata is available. Keys that couldn’t retrieve its associated data show an empty value:
- city
geoname_id
: integernames
: list
- continent
code
: stringgeoname_id
: integernames
: list
- country
geoname_id
: integeris_in_european_union
: booleaniso_code
: stringnames
: list
- location
accuracy_radius
: integerlatitude
: floatlongitude
: floatmetro_code
: integertime_zone
: string
- postal
code
: string
- registered_country
geoname_id
: integeris_in_european_union
: booleaniso_code
: stringnames
: list
- represented_country
geoname_id
: integeris_in_european_union
: booleaniso_code
: stringnames
: listtype
: string
- subdivisions
geoname_id
: integeriso_code
: stringnames
: list
- traits
is_anonymous_proxy
: booleanis_satellite_provider
: boolean