Apache 限制下载带宽, 限制访问并发数

限制访问带宽

Bandwidth Mod

http://ivn.cl/category/apache/

sudo apxs -c -i -a mod_bw.c

若没有apxs, 则需安装 apache2-dev

172923_1rPV_2485194.png

代码如下
listen 10004
NameVirtualHost *:10004
<VirtualHost *:10004>
 DocumentRoot "/home/zhangy/www/test"
 ServerName *:10004
 BandwidthModule On
 ForceBandWidthModule On
 Bandwidth all 1024000
 MinBandwidth all 50000
 LargeFileLimit * 500 50000
 MaxConnection all 6
 ErrorLog "/home/zhangy/apache/www.test.com-error.log"
 CustomLog "/home/zhangy/apache/www.test.com-error.log" common
</VirtualHost>

解压bandwidth的压缩文件后,里面有一个mod_bw.txt有详细的说明和实例,下面是部分参数说明:

1,BandWidth localhost 0                                      #对localhost不限速
2,BandWidth 192.168.1.5 102400                       #对192.168.1.5限速为100KB

3,BandWidth “u:^Mozilla(.*)” 10240              #用mozilla时限速10KB
4,BandWidth “u:wget” 102400                      #如果用wget下载时限速10KB

5,MinBandWidth all -1                                      #保证每个客户端最高速度可达10KB
6,LargeFileLimit .jpg 100 10240                      #jpg文件超过100KB,限速10KB

7,#下面的510挺好,如果不设置,apache自己会报错,就根报404差不多,页面非常的丑
ErrorDocument 510 /exceed_speed.html
BandWidthError 510

8,MaxConnection all 10                                       #所有ip最大连接数为10
9,MaxConnection 192.168.1.5 5                         #192.168.1.5最大连接数为5

转载于:https://my.oschina.net/u/2485194/blog/823419

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值