nginx 白名单访问控制
#nginx.conf
#方式一,geo模块将ip|ip段对应的 0|1 赋值给 $white
#https://tengine.taobao.org/nginx_docs/cn/docs/http/ngx_http_geo_module.html
geo $white {
default 0;
1.2.3.0/24 1;#白名单
}
#方式二,map模块,同上,支持变量 $http_host|$http_user_agent|$remote_addr...
#https://tengine.taobao.org/nginx_docs/cn/docs/http/ngx_http_map_module.html
map $http_host $h {
default 1;
example.org 0;
}
server
{
listen 80;
...
location ~ /aaaaa {
if ($white){
proxy_pass http://..;
}
}
}