Apache下使用Bandwidth Mod限制總頻寬

來源:互聯網
上載者:User

Apache下使用Bandwidth Mod限制總頻寬
環境:
CentOS release 5.6 + Apache 2.2.22
mod_bw v0.92
http://ivn.cl/files/source/mod_bw-0.92.tgz
mod_bw v0.92 文檔
http://legacy.ivn.cl/files/txt/mod_bw-0.92.txt
 
下載及安裝:
#wget http://ivn.cl/files/source/mod_bw-0.92.tgz
#tar zxvf mod_bw-0.92.tgz
#/data/apps/httpd2.2.22/bin/apxs -c -i -a mod_bw.c
配置VirtualHost
 
<VirtualHost *:80> 
DocumentRoot /data/webapps/www.domain.com 
ServerName www.domain.com 
 
<Location /> 
        SetEnvIfNoCase User-Agent "Googlebot" google 
        Order allow,deny 
        Allow from all 
        deny from env=google 
</Location> 
 
BandWidthModule On 
ForceBandWidthModule On 
BandWidth     all 131072 
</VirtualHost> 
 
其中<Location />***</Location> 段是為了拒絕Googlebot的抓取用的。
在沒有暴露連結地址的情況下,Google老來抓取檔案,原因不明。
當然這個可以robots.txt裡面寫上,但沒這個見效快。
下面是兩個概念(注意區分大小寫):
bps ( bits per second ) 位/秒 一般用作傳輸速率
Bps ( bytes per second ) 位元組/秒 一般用作顯示速度
1Byte = 8*1bit (1位元組=8字位)
而我們通常所講的2M頻寬、10M頻寬,一般是指10Mbit (10Mbps)
官方文檔上BandWidth的單位:BandWidth [From] [bytes/s]
所以如果要限制某個虛擬機器主機的總頻寬為1M,則:
 
BandWidth     all 131072 
 
// (1024*1024) bps/8 = 131072 Bps

摘自 JOM_CH

聯繫我們

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