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://..;
      }
    }
}
welcome come back
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!