安装GeoIp模块
1 |
|
下载ip库
1 |
|
修改nginx配置文件
1 | vi /etc/nginx/nginx.conf |
GeoIP参数
http://nginx.org/en/docs/http/ngx_http_geoip_module.html
Syntax: geoip_country file;
Default: —
Context: http
Specifies a database used to determine the country depending on the client IP address. The following variables are available when using this database:
$geoip_country_code
two-letter country code, for example, “RU”, “US”.
$geoip_country_code3
three-letter country code, for example, “RUS”, “USA”.
$geoip_country_name
country name, for example, “Russian Federation”, “United States”.
Syntax: geoip_city file;
Default: —
Context: http
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:
$geoip_area_code
telephone area code (US only).
This variable may contain outdated information since the corresponding database field is deprecated.
$geoip_city_continent_code
two-letter continent code, for example, “EU”, “NA”.
$geoip_city_country_code
two-letter country code, for example, “RU”, “US”.
$geoip_city_country_code3
three-letter country code, for example, “RUS”, “USA”.
$geoip_city_country_name
country name, for example, “Russian Federation”, “United States”.
$geoip_dma_code
DMA region code in US (also known as “metro code”), according to the geotargeting in Google AdWords API.
$geoip_latitude
latitude.
$geoip_longitude
longitude.
$geoip_region
two-symbol country region code (region, territory, state, province, federal land and the like), for example, “48”, “DC”.
$geoip_region_name
country region name (region, territory, state, province, federal land and the like), for example, “Moscow City”, “District of Columbia”.
$geoip_city
city name, for example, “Moscow”, “Washington”.
$geoip_postal_code
postal code.