使用nginx Limit Requests模块限制单个IP请求速率

2020-03-09 14:45:30

此模块可以限制单个客户端发送请求的速率。
示例配置:

http {
    limit_req_zone  $binary_remote_addr  zone=one:10m   rate=1r/s;
 
    ...
 
    server {
 
        ...
 
location ~ .*.(php|php5)?$
    {
       limit_req   zone=one  burst=5 nodelay;
        fastcgi_pass unix:/tmp/php-cgi-www.centos.bz.sock;
        fastcgi_index index.php;
        include fcgi.conf;
    }
...
    }

此示例配置是指限制单个客户端请求php动态文件的速率是每秒一个请求,峰值是5个请求。

相关新闻

相关游戏