企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 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")