nginx並發串連控制模組ngx_http_limit_conn_module

來源:互聯網
上載者:User

標籤:ati   預設值   返回   cat   取值   span   level   整數   作用   

模組: ngx_http_limit_conn_module

作用: 根據定義的key限制並發串連數

配置樣本:

http {    limit_conn_zone $binary_remote_addr zone=addr:10m;    ...    server {        ...        location /api/ {            limit_conn addr 10;            limit_conn_status 503;          }    }}

  

 說明: 樣本中定義key(zone=addr)為addr,分配記憶體大小為10m(zone=addr:10m)(如果限制域的儲存空間耗盡了,對於後續所有請求,伺服器都會返回 503),同一個ip($binary_remote_addr)和伺服器串連超過10個(limit_conn addr 10)將會被攔截並返回503(limit_conn_status 503)錯誤碼

 

涉及指令:

  limit_conn_zone 

  limit_conn 

  limit_conn_status 

  limit_conn_log_level 

 

指令詳解:
limit_conn_zone文法: limit_conn_zone key zone=name:size;(設定限制規則、地區名稱及分配的記憶體大小)可配置地區: httpkey: 必選項;設定限制規則;取值可以是text文本、nginx變數或兩者的組合;執行個體中使用的nginx變數$binary_remote_addr表示根據每個ip限制並發name: 必選項; 自訂一個地區名稱; 任一字元串size: 分配記憶體的大小

 

limit_conn 文法: limit_conn zone number; (使用由limit_conn_zone定義的攔截規則, 並設定具體的限制串連數量)可配置地區: http, server, locationzone: 必選項; 由limit_conn_zone(zone=name)定義的名稱; 表示使用定義的哪個限制規則number: 必選項; 正整數; 表示具體的限制串連數量

 

limit_conn_status 文法: limit_conn_status code;預設值: 503可配置地區: http, server, location表示超出limit_req配置的請求數量後返回給用戶端的錯誤碼使用該指令最低版本 1.3.15

  

limit_conn_log_level 文法: limit_conn_log_level info | notice | warn | error;預設值: limit_conn_log_level error;可配置地區: http, server, location當伺服器拒絕處理由於速率超過或延遲請求處理而拒絕處理請求時,設定所需的日誌記錄層級。最低版本: 0.8.18

  

  

  

 

nginx並發串連控制模組ngx_http_limit_conn_module

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.