如何限制 Apache 的带宽流量

Posted by seobib 2 September,2010 (0)Comment

Dapper 下的 apache2 的 带宽流量限制

首先确认安装好apache2.

安装 libapache2-mod-cband

apt-get install libapache2-mod-cband

激活 cband 模块

cd /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/cband.conf cband.conf    (-s : 进行软链结(symbolic link) )
ln -s /etc/apache2/mods-available/cband.load cband.load

升级 libapache2-mod-cband

apt-get install apache2-prefork-devcd /tmpwget cband.linux.pl/download/mod-cband-0.9.7.4.tgztar xzvf mod-cband-0.9.7.4.tgzcd mod-cband-0.9.7.4./configuremakemake install

由于cband模块已经由 cband.load 加载,因此修改 /etc/apache2/httpd.conf ,删除加入cband_module的行。

vim  /etc/apache2/httpd.conf

查找

LoadModule cband_module       /usr/lib/apache2/modules/mod_cband.so

删除,并保存。

设置站点:

<VirtualHost 1.2.3.4>ServerName www.example.comServerAdmin webmaster@example.comDocumentRoot /var/wwwCBandSpeed 1024 10 30  #(请求数目和链接数目)CBandRemoteSpeed 20kb/s 3 3</VirtualHost>CBandSpeed 限制 www.example.com 的虚拟主机的总访问速度为 1024kbps, 最大每秒 10 个请求和最大每秒 30 个连接. 

CBandRemoteSpeed 限制 www.example.com 的虚拟主机的任何个人的访问速度为每秒 20kb, 最大每秒 3 个请求和最大每秒 3 个连接.

重新启动 apahe2 使其配置生效:

/etc/init.d/apache2 restart

你同时可以通过url:

http://www.example.com/cband-statushttp://www.example.com/cband-status-me 来查看最新的流量情况。 

Related Items

Categories : 网络安全 Tags :
Comments
Leave a comment

Or, take a look at Archives and Categories

Category

Archives