成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

nginx limit配置參數(shù)解讀

Jonathan Shieber / 3576人閱讀

本文主要解析一下ngx_http_core_module、ngx_http_limit_conn_module以及ngx_http_limit_req_module中的limit相關(guān)配置參數(shù)。

limit_rate
名稱 默認(rèn)配置 作用域 官方說(shuō)明 中文解讀 模塊
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過(guò)后將啟動(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;
            }
        }
limit_conn
名稱 默認(rèn)配置 作用域 官方說(shuō)明 中文解讀 模塊
limit_conn 沒有默認(rèn)值,語(yǔ)法 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. 指定一個(gè)zone的每個(gè)key最大連接數(shù) ngx_http_limit_conn_module
limit_conn_zone 沒有默認(rèn)值,語(yǔ)法 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. 第一個(gè)參數(shù)是key,第二個(gè)參數(shù)是指定zone及其存放元數(shù)據(jù)(key,current num of conns per key,zone size)的共享內(nèi)存大小 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. 指定當(dāng)觸發(fā)limit的時(shí)候日志打印級(jí)別 ngx_http_limit_conn_module

實(shí)例

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
名稱 默認(rèn)配置 作用域 官方說(shuō)明 中文解讀 模塊
limit_req 沒有默認(rèn)值,語(yǔ)法 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 沒有默認(rèn)值,語(yǔ)法 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. 第一個(gè)參數(shù)指定key,第二個(gè)參數(shù)指定zone名稱和元數(shù)據(jù)的內(nèi)存大小,第三個(gè)參數(shù)rate指定單位時(shí)間的請(qǐng)求數(shù)閾值 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. 指定觸發(fā)req limit時(shí)打印的日志級(jí)別 ngx_http_limit_req_module

實(shí)例

http {
 limit_req_zone $binary_remote_addr zone=myreqzone:10m
 limit_req_log_level warn;

 server {
    ## 每個(gè)ip限定10個(gè)連接數(shù)
    ## 正常一個(gè)瀏覽器給每個(gè)host開兩到三個(gè)連接
    ## 觸發(fā)的話會(huì)返回503
    ## nodelay表示一上來(lái)就直接計(jì)算,不經(jīng)過(guò)一些預(yù)熱后再計(jì)算
    limit_req zone=myreqzone burst=10 nodelay;
 }
}
doc

ngx_http_core_module

ngx_http_limit_conn_module

ngx_http_limit_req_module

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/39750.html

相關(guān)文章

  • nginx http模塊配置參數(shù)解讀

    摘要:名稱默認(rèn)配置作用域官方說(shuō)明中文解讀模塊是否開啟對(duì)后端的緩沖指定一個(gè)連接到代理服務(wù)器的超時(shí)時(shí)間,單位為秒,需要注意的是這個(gè)時(shí)間最好不要超過(guò)秒。 序 本文主要解析一下nginx http模塊配置參數(shù)。主要分socket相關(guān)參數(shù),對(duì)clinet請(qǐng)求的buffer參數(shù)以及對(duì)response的buffer參數(shù)。 socket 名稱 默認(rèn)配置 作用域 官方說(shuō)明 中文解讀 模塊 sendf...

    pf_miles 評(píng)論0 收藏0
  • Nginx 對(duì)訪問(wèn)量的控制

    摘要:目的了解的和模塊,對(duì)請(qǐng)求訪問(wèn)量進(jìn)行控制。即對(duì)并發(fā)和并行的控制,這兩個(gè)功能分別由和模塊負(fù)責(zé)實(shí)現(xiàn)。模塊說(shuō)明該模塊主要用于對(duì)請(qǐng)求并發(fā)量進(jìn)行控制。 目的 了解 Nginx 的 ngx_http_limit_conn_module 和 ngx_http_limit_req_module 模塊,對(duì)請(qǐng)求訪問(wèn)量進(jìn)行控制。 Nginx 模塊化 nginx 的內(nèi)部結(jié)構(gòu)是由核心模塊和一系列的功能模塊所組成。...

    AndroidTraveler 評(píng)論0 收藏0
  • Nginx http資源請(qǐng)求限制(三種方法)

    摘要:將延遲處理此類請(qǐng)求,直到存儲(chǔ)區(qū)共享存儲(chǔ)區(qū)已滿。因此,如果目標(biāo)是阻止下載速度大于指定值,則連接數(shù)也應(yīng)該受到限制。以下示例顯示了用于限制連接數(shù)和帶寬的組合配置。 原文鏈接:何曉東 博客 前置條件:nginx 需要有 ngx_http_limit_conn_module 和 ngx_http_limit_req_module 模塊,可以使用命令 2>&1 nginx -V | tr ...

    stormzhang 評(píng)論0 收藏0
  • Nginx http資源請(qǐng)求限制(三種方法)

    摘要:將延遲處理此類請(qǐng)求,直到存儲(chǔ)區(qū)共享存儲(chǔ)區(qū)已滿。因此,如果目標(biāo)是阻止下載速度大于指定值,則連接數(shù)也應(yīng)該受到限制。以下示例顯示了用于限制連接數(shù)和帶寬的組合配置。 原文鏈接:何曉東 博客 前置條件:nginx 需要有 ngx_http_limit_conn_module 和 ngx_http_limit_req_module 模塊,可以使用命令 2>&1 nginx -V | tr ...

    mayaohua 評(píng)論0 收藏0
  • Nginx-基礎(chǔ)篇

    摘要:四優(yōu)勢(shì)多路復(fù)用輕量級(jí)功能模塊少代碼模塊少親和把核心和工作進(jìn)程綁定,把每個(gè)進(jìn)程固定在一個(gè)上執(zhí)行,減少切換的,獲得更好的性能。 Nginx-基礎(chǔ)篇 一、環(huán)境: 系統(tǒng)硬件:CPU>=2Core,內(nèi)存>=256M 操作系統(tǒng):CentOS 7.2 x64 二、環(huán)境調(diào)試確認(rèn): 1、四個(gè)確認(rèn) 確認(rèn)系統(tǒng)網(wǎng)絡(luò) ping www.baidu.com 確認(rèn)yum可用 yum list 確認(rèn)...

    April 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<