网站建设资讯

NEWS

网站建设资讯

解读nginx中limit配置参数-创新互联

本文主要解析一下ngx_http_core_module、ngx_http_limit_conn_module以及ngx_http_limit_req_module中的limit相关配置参数。

创新互联建站-云计算及IDC服务提供商,涵盖公有云、IDC机房租用、成都多线服务器托管、等保安全、私有云建设等企业级互联网基础服务,服务电话:028-86922220

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;
      }
    }

网站标题:解读nginx中limit配置参数-创新互联
本文网址:http://cdweb.net/article/dpijjj.html