标签:style 配置文件 ssl inf open png 个人 set none
1. Nginx HTTP 块配置,此区块只做配置列表,并无限制条约,置如下
geoip2 /usr/local/nginx/GeoIP/GeoLite2-Country.mmdb {
$geoip2_data_country_code country iso_code;
}
#允许本地网段访问
geo $allow-ip{
default no;
192.168.10.0/24
}
#配置地区访问
map $geoip2_data_country_code $allowed_country {
default no;
CN yes;
}

2. server 块主要启用上属所定义的配置限制要求,配置如下;
此配置在location 前面,也可以配置在localtion 里面,经测试如自定义403 404 异常返回页面,将放置到localtion 里面自定义页面才可生效;
#自定义403 404 返回页面
error_page 403 404 /403.html;
location = /403.html {
root /var/www/;
}
location / {
#本地网段白名单
if ($allow-ip = yes ) {
set $allowed_country yes;
}
#国家地区白名单
if ($allowed_country = no) {
return 403;
}
proxy_pass http://huangting_web;
include conf.d/proxy.conf;
}

3. 备注:个人所在配置时启用SSL , 配置文件与nginx.conf 使用include 外部调用,所有在nginx -t 测试提示ssl on 的配置异常,重启使用时测试正常
Nginx 配置GeoIP2 禁止访问,并允许添加白名单过滤访问设置
标签:style 配置文件 ssl inf open png 个人 set none
原文地址:https://www.cnblogs.com/itusye/p/11926980.html