今天是: 收藏本站 设为主页
网站首页 >  技术专栏  >  linux  > 

apache bandwidth limit 限制下载带宽

日期:2012-02-01  点击率:1288


apt-cache search apache | grep band
libapache2-mod-bw – bandwidth limiting module for apache2

apt-cache search libapache2 //看看apache2 都有些什么可用的模块

sudo apt-get install libapache2-mod-bw

/etc/apache2/mods-available$ cat bw.load
LoadModule bw_module /usr/lib/apache2/modules/mod_bw.so

/etc/apache2/mods-enabled$ sudo ln -s ../mods-available/bw.load bw.load

<Virtualhost *>
BandWidthModule On
ForceBandWidthModule On //catch each request
BandWidth all 10240 //total bw 10K
MaxConnection all 3 //max connect 3
LargeFileLimit * 1024 1024 //file size > 1024K limited to 1K
<Virtualhost *>

sudo /etc/init.d/apache2 reload

mod_bw完整配置文档
http://legacy.ivn.cl/files/txt/mod_bw-0.8.txt

http://modules.apache.org/

 

This example, makes everyone have 50kb as top speed.

       BandWidth    all 50000       MinBandWidth all -1

Limit every user to a max of 100Kb/s on a vhost :

<Virtualhost *>

  BandwidthModule On

  ForceBandWidthModule On

  Bandwidth all 102400

  MinBandwidth all -1

  Servername www.example.com

</Virtualhost>

 

Mine:

<Virtualhost *>

  BandwidthModule On

  ForceBandWidthModule On

  Bandwidth all 307200

  MinBandwidth all -1

  MaxConnection all 50

  Servername www.example.com

</Virtualhost>





下一篇:13个常用CSS和HTML快速开发工具   上一篇:开发者需了解10个新的开源项目