Limits the rate of response transmission to a client. The rate is specified in bytes per second. The zero value disables rate limiting. The limit is set per a request, and so if a client simultaneously opens two connections, the overall rate will be twice as much as the specified limit.
指定每秒该连接能下载的bytes,主要用来限制个别请求的带宽
ngx_http_core_module
limit_rate_after
limit_rate_after 0;
http, server, location, if in location
Sets the initial amount after which the further transmission of a response to a client will be rate limited.
设置多少bytes过后将启动limit计数,如果小于此值则不限速
ngx_http_core_module
limit_except
没有默认值
location
Limits allowed HTTP methods inside a location. The method parameter can be one of the following: GET, HEAD, POST, PUT, DELETE, MKCOL, COPY, MOVE, OPTIONS, PROPFIND, PROPPATCH, LOCK, UNLOCK, or PATCH. Allowing the GET method makes the HEAD method also allowed
Sets the shared memory zone and the maximum allowed number of connections for a given key value. When this limit is exceeded, the server will return the error in reply to a request.
指定一个zone的每个key最大连接数
ngx_http_limit_conn_module
limit_conn_zone
没有默认值,语法 limit_conn_zone key zone=name:size;
http
Sets parameters for a shared memory zone that will keep states for various keys. In particular, the state includes the current number of connections. The key can contain text, variables, and their combination. Requests with an empty key value are not accounted.
第一个参数是key,第二个参数是指定zone及其存放元数据(key,current num of conns per key,zone size)的共享内存大小
ngx_http_limit_conn_module
limit_conn_log_level
limit_conn_log_level error;
http, server, location
Sets the desired logging level for cases when the server limits the number of connections. This directive appeared in version 0.8.18.
指定当触发limit的时候日志打印级别
ngx_http_limit_conn_module
实例
http {
limit_conn_zone $binary_remote_addr zone=ips:10m;
limit_conn_zone $server_name zone=servers:10m;
limit_conn_log_level notice;
server {
# these limits apply to the whole virtual server
limit_conn ips 10;
# only 1000 simultaneous connections to the same server_name
limit_conn servers 1000;
}
}
Sets the shared memory zone and the maximum burst size of requests. If the requests rate exceeds the rate configured for a zone, their processing is delayed such that requests are processed at a defined rate. Excessive requests are delayed until their number exceeds the maximum burst size in which case the request is terminated with an error.
Sets parameters for a shared memory zone that will keep states for various keys. In particular, the state stores the current number of excessive requests. The key can contain text, variables, and their combination. Requests with an empty key value are not accounted.
Sets the desired logging level for cases when the server refuses to process requests due to rate exceeding, or delays request processing. Logging level for delays is one point less than for refusals.