Nginx - rate limit for connection from different user agent

Hello. 
Trying to set a rate limit for user agent using nginx on the Hestia CP .

1. In http section of the main nginx configuration /etc/nginx/nginx.conf add this code

http {

...

   map $http_user_agent $limit_bots {

      default '';

      ~*(yandex|msnbot|yahoo) $binary_remote_addr;

   }

   limit_req_zone $limit_bots zone=bots:10m rate=40r/m;

...

}

In the configuration file of the vhost  need add this code

server {
...
   limit_req zone=bots burst=5 nodelay;
...

}



PS.
source article 

Comments

Popular posts from this blog

Debian 12 (Proxmox Mail Gateway) and starting mailCow mail service

Відновлення роботи роботи роутера Linksys WRT54G3G-ST після невдалого обновлення прошивки.