本文主要解析一下ngx_http_core_module、ngx_http_limit_conn_module以及ngx_http_limit_req_module中的limit相关配置参数。
limit_rate
名称
默认配置
作用域
官方说明
中文解读
模块
limit_rate
limit_rate 0;
http, server, location, if in location
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
设置除了指定的http methods外其他method将被限制,允许GET就自动允许HEAD方法
ngx_http_core_module
实例
location /downloads { limit_rate_after 1m; limit_rate 500k; } location / { proxy_pass http://localhost:3000; limit_except GET { deny all; } }
limit_conn
名称
默认配置
作用域
官方说明
中文解读
模块
limit_conn
没有默认值,语法 limit_conn zone number;
http, server, location
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; } }
limit_req
名称
默认配置
作用域
官方说明
中文解读
模块
limit_req
没有默认值,语法 limit_req zone=name [burst=number] [nodelay];
http, server, location
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.
指定zone的burst大小
ngx_http_limit_req_module
limit_req_zone
没有默认值,语法 limit_req_zone key zone=name:size rate=rate;
http
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.
第一个参数指定key,第二个参数指定zone名称和元数据的内存大小,第三个参数rate指定单位时间的请求数阈值
ngx_http_limit_req_module
limit_req_log_level
limit_req_log_level error;
http, server, location
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.
指定触发req limit时打印的日志级别
ngx_http_limit_req_module
实例
http { limit_req_zone $binary_remote_addr zone=myreqzone:10m limit_req_log_level warn; server { ## 每个ip限定10个连接数 ## 正常一个浏览器给每个host开两到三个连接 ## 触发的话会返回503 ## nodelay表示一上来就直接计算,不经过一些预热后再计算 limit_req zone=myreqzone burst=10 nodelay; } }
以上就是我们整理的nginx中limit配置参数的全部内容,大家可以在下方的留言区讨论,感谢你对的支持。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]