### HttpLimitReqest妯″潡
This module allows you to limit the number of requests for a given session, or as a special case, with one address.
Restriction done using leaky bucket.
### Example Configuration
~~~
http {
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
...
server {
...
location /search/ {
limit_req zone=one burst=5;
}
~~~
### 鎸囦护
**Syntax:***limit_req_zone **$session_variable** zone=**name_of_zone**:**size** rate=**rate***
**Default:***none*
**Context:***http*
The directive describes the area, which stores the state of the sessions. The values of the sessions is determined by the given variable. Example of usage:
~~~
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
~~~
In this case, the session state is allocated 10MB as a zone called "one", and the average speed of queries for this zone is limited to 1 request per second.
The sessions are tracked per-user in this case, but note that instead of the variable $remote_addr, we've used the variable $binary_remote_addr, reducing the size of the state to 64 bytes. A 1 MB zone can hold approximately 16000 states of this size.
The speed is set in requests per second or requests per minute. The rate must be an integer, so if you need to specify less than one request per second, say, one request every two seconds, you would specify it as "30r/m".
**Syntax:***limit_req zone=**zone** burst=**burst** [nodelay]*
**Default:***none*
**Context:***http, server, location*
The directive specifies the zone (**zone**) and the maximum possible bursts of requests (burst). If the rate exceeds the demands outlined in the zone, the request is delayed, so that queries are processed at a given speed. Excess requests are delayed until their number does not exceed a specified number of bursts. In this case the request is completed the code "Service unavailable" (503). By default, the burst is zero.
For example, the directive
~~~
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server {
location /search/ {
limit_req zone=one burst=5;
}
~~~
allows a user no more than 1 request per second on average, with bursts of no more than 5 queries. If the excess requests within the limit burst delay are not necessary, you should use the nodelay:
~~~
limit_req zone=one burst=5 nodelay;
~~~
- 主要文档
- Nginx功能概述
- 为什么选择Nginx
- Nginx安装
- 运行和控制Nginx
- 配置符号参考
- 优化 Nginx
- 常见问题(FAQ)
- 调试 nginx
- 核心模块
- Nginx主模块
- Nginx事件模块
- 基本模块
- http核心模块
- HttpIndex模块
- HttpAccess模块
- HttpAuthBasic模块
- HttpAutoindex模块
- Browser模块
- Charset模块
- HttpEmptyGif模块
- HttpFcgi模块
- Geo模块
- HttpGzip模块
- HttpHeaders模块
- HttpIndex模块
- HttpReferer模块
- HttpLimit zone
- HttpLimitReqest模块
- HttpLog模块
- map
- Memcached
- HttpProxy模块
- HttpRewrite模块
- HttpSSI模块
- HttpUserId
- 其他模块
- Addition模块
- EmbeddedPerl
- flv
- HttpGzipStatic
- RandomIndex
- HttpGeoIP
- HttpRealIp
- HttpSSL
- StubStatus模块
- HttpSubstitution
- HttpDav模块
- GooglePerftools
- HttpXSLT
- HttpSecureLink
- HttpImageFilter
- mail模块
- MailCore
- MailAuth
- MailProxy
- MailSSL
- 安装
- nginx在windows上的安装
- nginx在freebsd上的安装
- nginx在ubuntu上的安装
- nginx在fedora上的安装
- nginx php-fpm安装配置
- 配置示例和方法
- 完整例子
- 完整例子2
- 虚拟主机
- 负载均衡
- nginx防盗链
- HWLoadbalancerCheckErrors