利用nginx實現文檔伺服器限速

來源:互聯網
上載者:User

標籤:下載速度   伺服器   nginx   

在平時工作中,我們為了一些軟體文檔方便查看通常會搭建一些目錄服務(類似yum源),為控制下載速度和下載總數,我們可以利用nginx的ngx_http_limit_conn_module模組。

首先在http段添加如下配置:

limit_conn_zone $binary_remote_addr zone=perip:10m;limit_conn_zone $server_name zone=perserver:10m;

在對應的location中添加如下配置,雖然這個模組範圍可以是http,server,location,但是為了不影響其他的服務,只針對下載服務,因此在location中添加:

location /down {        autoindex on;        autoindex_exact_size off;        autoindex_localtime on;        limit_conn perip 1;        limit_conn perserver 100;        limit_conn_status 505;        limit_rate_after 500k;        limit_rate 100k;        root html;    }

同時為了頁面友好,在server中定義下505的指定頁面:

error_page  555    /hello;

儲存配置,重啟nginx。

配一個被限制的圖650) this.width=650;" src="http://img.baidu.com/hi/jx2/j_0005.gif" alt="j_0005.gif" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/7F/AA/wKioL1coZXzyoOkQAACxySam9iU997.png" title="QQ20160503163907.png" alt="wKioL1coZXzyoOkQAACxySam9iU997.png" />

本文出自 “各種軟體使用者” 部落格,請務必保留此出處http://yaoyf.blog.51cto.com/4223135/1769770

利用nginx實現文檔伺服器限速

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.