Nginx GeoIP2模块
http {
geoip_country /usr/local/nginx/geoip.dat;
map $geoip_country_code $allowed_country {
default no; # 默认不允许,如果改为 yes 表示默认允许
CN yes; #区域允许,这个CN就是代表中国,如果是多个地区,就是CN下面加就行
}
}
- 需要下载 geoip.dat ip库
- 下载地址https://dolphincn.github.io/images/nginx/geoip/geoip.dat.gz
- 下载后解压得到geoip.dat文件

浙公网安备 33010602011771号