### HttpGeoIP
This module creates ngx_http_geoip_module variables based on the IP-address of the client matched against the [MaxMind](http://www.maxmind.com/ "http://www.maxmind.com/") GeoIP binary files. This module appeared in nginx version 0.8.6.
本模塊ngx_http_geoip_module的變量基于IP地址匹配[MaxMind](http://www.maxmind.com/) GeoIP 二進制文件. 這個模塊開始出現在nginx0.8.6。
Precondition 首先
This module needs the geo databases and the library to read the database.
模塊必需有geo數據庫和讀取數據庫類
~~~
#下載免費的geo_city數據庫
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#下載免費的geo_coundty數據庫
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
#在debian中安裝libgeoip:
sudo apt-get install libgeoip-dev
#其它系統,你可以下載并編譯一個源文件
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
~~~
在centos可以用yum安裝:
~~~
yum install geoip
~~~
編譯
~~~
./configure --with-http_geoip_module
~~~
例如
~~~
http {
geoip_country GeoIP.dat;
geoip_city GeoLiteCity.dat;
...
~~~
### 指令
### geoip_country
**syntax:***geoip_country path/to/db.dat;*
**default:** none
**context:***http*
The directive indicates the path to the .dat file used for determining the visitor's country from the IP-address of the client. When set the module makes available the following variables:
dat文件用于判斷訪問者IP中的國家。當前模塊 下可用的變量 :
- $geoip_country_code; -國家名的前兩個字母, 如, "RU", "US".
- $geoip_country_code3; - 國家名的前三個字母, 如, "RUS", "USA".
- $geoip_country_name; -國家名稱, 如, "Russian Federation", "United States".
If you only need the country's name, you can just set the geoip_country database(1.1M), while the geoip_city database is much bigger(43M) and all the databses will be cached in memory.
如果你只需要國家,你只需設置geoip_country數據庫(1.1M), 但城市的ip數據庫就比較大(43M)并且將加載到內存當緩存。
### geoip_city
**syntax:***geoip_city path/to/db.dat;*
**default:** none
**context:***http*
The directive indicates the path to the .dat file used for determining countries, regions and cities from IP-address of the client. When set the module makes available the following variables:
dat文件用于判斷訪問者IP中的國家、省,城市。當前模塊 下可用的變量:
- $geoip_city_country_code; -國家名的前兩個字母, 如, "RU", "US".
- $geoip_city_country_code3; - 國家名的前三個字母, 如, "RUS", "USA".
- $geoip_city_country_name; -國家名稱, 如, "Russian Federation", "United States".
- $geoip_region; - 省,州或區名 (province, region, state, province, federal land, and the like), 如, "Moscow City", "DC".
- $geoip_city; - 城市名稱, 如, "Moscow", "Washington".
- $geoip_postal_code; - 郵政編號.
### References
[Original Documentation](http://sysoev.ru/nginx/docs/http/ngx_http_geoip_module.html "http://sysoev.ru/nginx/docs/http/ngx_http_geoip_module.html")
- 主要文檔
- Nginx功能概述
- 為什么選擇Nginx
- Nginx安裝
- 運行和控制Nginx
- 配置符號參考
- 優化 Nginx
- 常見問題(FAQ)
- 調試 nginx
- 核心模塊
- Nginx主模塊
- Nginx事件模塊
- 基本模塊
- http核心模塊
- HttpIndex模塊
- HttpAccess模塊
- HttpAuthBasic模塊
- HttpAutoindex模塊
- Browser模塊
- Charset模塊
- HttpEmptyGif模塊
- HttpFcgi模塊
- Geo模塊
- HttpGzip模塊
- HttpHeaders模塊
- HttpIndex模塊
- HttpReferer模塊
- HttpLimit zone
- HttpLimitReqest模塊
- HttpLog模塊
- map
- Memcached
- HttpProxy模塊
- HttpRewrite模塊
- HttpSSI模塊
- HttpUserId
- 其他模塊
- Addition模塊
- EmbeddedPerl
- flv
- HttpGzipStatic
- RandomIndex
- HttpGeoIP
- HttpRealIp
- HttpSSL
- StubStatus模塊
- HttpSubstitution
- HttpDav模塊
- GooglePerftools
- HttpXSLT
- HttpSecureLink
- HttpImageFilter
- mail模塊
- MailCore
- MailAuth
- MailProxy
- MailSSL
- 安裝
- nginx在windows上的安裝
- nginx在freebsd上的安裝
- nginx在ubuntu上的安裝
- nginx在fedora上的安裝
- nginx php-fpm安裝配置
- 配置示例和方法
- 完整例子
- 完整例子2
- 虛擬主機
- 負載均衡
- nginx防盜鏈
- HWLoadbalancerCheckErrors