大龙的博客

常用链接

统计

最新评论

使用mod_limitipconn和bw_mod实现Apache限速

近几天单位某个分网站下载量过大,导致服务器负载很高,拖得其他网站访问也很慢。限速喽~
网上查了下,Apache限速一般都是通过mod_limitipconn和bw_mod两个模块实现。
mod_limitipconn
限制每IP的连接数
mod_bandwidth
限制目录总的带宽使用
话不多说,开始安装:
➩ 首先安装bw_mod模块,官方网站: http://www.ivn.cl/apache/
我是用DSO安装的apache,所以也使用apxs来安装插件,指令如下:
# tar zxvf mod_bw-0.8.tgz
# cd mod_bw
# $APACHE_HOME/bin/apxs -i -a -c mod_bw.c
设置Apache的conf文件:
BandWidthModule
OnForceBandWidthModule On
BandWidth 211.67.64.0/255.255.255.0 100000 //211.67.64.0的用户带宽限制为100K
BandWidth all 10000 //其他用户带宽限制为10K
LargeFileLimit .avi 500 10000 //文件大小超过500K的avi文件限制为10K
// 定义错误码和错误页面
ErrorDocument 510 /errors/maxconexceeded.html
BandWidthError 510

➩ 接下来安装mod_limitipconn模块,官方网站:http://dominia.org/djao/limitipconn2.html
仍然使用DSO的方式来安装这个插件,命令如下:
# tar zxvf mod_limitipconn-0.22.tar.gz
# cd mod_limitipconn-0.22
修改Makefile文件,指定apxs和apachectl的位置
# make install
设置Apache的conf文件:
ExtendedStatus On
LoadModule limitipconn_module mod_limitipconn.so
# 可以将IP线程限制加到虚拟主机里面
<VirtualHost www.abc.cn>
ServerAdmin webmaster@abc.cn
DocumentRoot /data/webapp/abc
ServerName www.abc.cn
<IfModule mod_limitipconn.c>
<Location /bigfiles>//注意这里是虚拟主机根目录下的文件夹
MaxConnPerIP 5
# 在此目录中,除了image文件之外每IP最多保持5个连接
NoIPLimit image/*
MaxConnPerIP 1
</Location>
<Location /mp3>
MaxConnPerIP 1
# 在此目录中,对于audio音频文件每IP最多保持1个连接
OnlyIPLimit audio/mpeg video
</Location>
</IfModule>
</VirtualHost>

重启Apache,完成限速。

posted on 2009-09-14 12:16 大龙 阅读(2492) 评论(6)  编辑 收藏 引用

评论

# re: 使用mod_limitipconn和bw_mod实现Apache限速 2010-08-02 16:01 PalmerEARNESTINE21

That's well known that money makes us independent. But how to act when one doesn't have money? The one way only is to receive the <a href="http://bestfinance-blog.com/topics/personal-loans">personal loans</a> or sba loan.   回复  更多评论   

# re: 使用mod_limitipconn和bw_mod实现Apache限速 2010-08-05 21:42 term paper

No matter they say just about progressive term papers, I do notfend! I have well-tried it at first-ever and loved it! Progressive research paper support team is so speedy! If you never did you should. These things are fun and fun is nice!  回复  更多评论   

# re: 使用mod_limitipconn和bw_mod实现Apache限速 2010-09-04 10:04 presentation and speech writing

Generally, college students don't like the essay thesis writing, but they still must present their creative writing ability! Therefore, some essay writing online service should be a great assistant for term papers writing.   回复  更多评论   

# re: 使用mod_limitipconn和bw_mod实现Apache限速 2011-09-30 01:38 Buy essay papers online

I don't think I am lazy to accomplish research essays. I do not have strong writing skills. Thus, I Pay to write essay and I do not feel shamed.   回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理