nginx限制压测软件对本站进行压测

Nginx  

开发项目自己需要压测,但是不希望他人压测自己的项目,nginx可以判断user_agent标识符限制具体配置如下

  1. server
  2. {
  3. listen 80;
  4. index index.php index.html index.htm default.php default.htm default.html;
  5. root /www/wwwroot/laravel/public;
  6. if ($http_user_agent ~ ApacheBench|WebBench|Java/|http_localhost_revalidate|wget) {
  7. return 403;
  8. }
  9. }

主要是这句,注意if后面的空格

  1. if ($http_user_agent ~ ApacheBench|WebBench|Java/|http_localhost_revalidate|wget) {
  2. return 403;
  3. }


评论 0

发表评论

Top