nginx 访问控制

nginx 访问控制

  • 可以匹配正则
location ~ .*(abc|image)/.*\.php$
{
        deny all;
}
  • 根据user_agent限制
if ($http_user_agent ~ 'Spider/3.0|YoudaoBot|Tomato')
{
      return 403;
}
 deny all和return 403效果一样
  • 测试使用curl -A Tomato 或者 curl --user-agent Tomato 进行模拟代理

posted on 2018-01-07 22:58  游荡的鱼  阅读(148)  评论(0编辑  收藏  举报

导航