本文主要解析一下ngx_http_core_module、ngx_http_limit_conn_module以及ngx_http_limit_req_module中的limit相關(guān)配置參數(shù)。
創(chuàng)新互聯(lián)建站-云計(jì)算及IDC服務(wù)提供商,涵蓋公有云、IDC機(jī)房租用、成都多線服務(wù)器托管、等保安全、私有云建設(shè)等企業(yè)級(jí)互聯(lián)網(wǎng)基礎(chǔ)服務(wù),服務(wù)電話:028-86922220limit_rate
名稱 | 默認(rèn)配置 | 作用域 | 官方說明 | 中文解讀 | 模塊 |
---|---|---|---|---|---|
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,主要用來(lái)限制個(gè)別請(qǐng)求的帶寬 | 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. | 設(shè)置多少bytes過后將啟動(dòng)limit計(jì)數(shù),如果小于此值則不限速 | ngx_http_core_module |
limit_except | 沒有默認(rèn)值 | 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 | 設(shè)置除了指定的http methods外其他method將被限制,允許GET就自動(dòng)允許HEAD方法 | ngx_http_core_module |
實(shí)例
location /downloads { limit_rate_after 1m; limit_rate 500k; } location / { proxy_pass http://localhost:3000; limit_except GET { deny all; } }