GeoIP#
Creates variables with values depending on the client IP address, using the precompiled MaxMind databases.
When using the databases with IPv6 support, IPv4 addresses are looked up as IPv4-mapped IPv6 addresses.
When building from the source code,
this module isn't built by default;
it should be enabled with the
‑‑with‑stream_geoip_module
build option.
Important
This module requires the MaxMind GeoIP library.
Configuration Example#
stream {
geoip_country GeoIP.dat;
geoip_city GeoLiteCity.dat;
map $geoip_city_continent_code $nearest_server {
default example.com;
EU eu.example.com;
NA na.example.com;
AS as.example.com;
}
# ...
}
Directives#
geoip_country#
Specifies a database used to determine the country depending on the client IP address. The following variables are available when using this database:
|
two-letter country code, for example, "RU", "US". |
|
three-letter country code, for example, "RUS", "USA". |
|
country name, for example, "Russian Federation", "United States". |
geoip_city#
Specifies a database used to determine the country, region, and city depending on the client IP address. The following variables are available when using this database:
|
two-letter continent code, for example, "EU", "NA". |
|
two-letter country code, for example, "RU", "US". |
|
three-letter country code, for example, "RUS", "USA". |
|
country name, for example, "Russian Federation", "United States". |
|
DMA region code in US (also known as "metro code"), according to the geotargeting in Google AdWords API. |
|
latitude. |
|
longitude. |
|
two-symbol country region code (region, territory, state, province, federal land and the like), for example, "48", "DC". |
|
country region name (region, territory, state, province, federal land and the like), for example, "Moscow City", "District of Columbia". |
|
city name, for example, "Moscow", "Washington". |
|
postal code. |
geoip_org#
Specifies a database used to determine the organization depending on the client IP address. The following variable is available when using this database:
|
organization name, for example, "The University of Melbourne". |