nginx

Nginx 安装 GEOIP实现屏蔽指定城市访问

# yum -y install zlib zlib-devel
# wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
# tar -zxvf GeoIP.tar.gz
# cd GeoIP-1.4.8
# ./configure
# make
# make install
# wget https://nginx.org/download/nginx-1.12.2.tar.gz
# tar zxvf nginx-1.12.2.tar.gz
# cd nginx-1.12.2
# ./configure --user=nginx --group=nginx \
    --with-http_geoip_module \
    --with-http_ssl_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_random_index_module \
    --with-http_secure_link_module \
    --with-http_stub_status_module \
    --with-mail \
    --with-mail_ssl_module \
    --with-file-aio
# make && make install
$geoip_country_code; – 两个字母的国家代码,如:”RU”, “US”。

$geoip_country_code3; – 三个字母的国家代码,如:”RUS”, “USA”。

$geoip_country_name; – 国家的完整名称,如:”Russian Federation”, “United States”。

$geoip_region – 地区的名称(类似于省,地区,州,行政区,联邦土地等),如:”30”。 30代码就是广州的意思

$geoip_city – 城市名称,如”Guangzhou”, “ShangHai”(如果可用)。

$geoip_postal_code – 邮政编码。

$geoip_city_continent_code$geoip_latitude – 所在维度。

$geoip_longitude – 所在经度。
CN,01,”Anhui”
CN,02,”Zhejiang”
CN,03,”Jiangxi”
CN,04,”Jiangsu”
CN,05,”Jilin”
CN,06,”Qinghai”
CN,07,”Fujian”
CN,08,”Heilongjiang”
CN,09,”Henan”
CN,10,”Hebei”
CN,11,”Hunan”
CN,12,”Hubei”
CN,13,”Xinjiang”
CN,14,”Xizang”
CN,15,”Gansu”
CN,16,”Guangxi”
CN,18,”Guizhou”
CN,19,”Liaoning”
CN,20,”Nei Mongol”
CN,21,”Ningxia”
CN,22,”Beijing”
CN,23,”Shanghai”
CN,24,”Shanxi”
CN,25,”Shandong”
CN,26,”Shaanxi”
CN,28,”Tianjin”
CN,29,”Yunnan”
CN,30,”Guangdong”
CN,31,”Hainan”
CN,32,”Sichuan”
CN,33,”Chongqing”