mod_cband是一個透過Apache 2模塊來解決限制用戶和虛擬主機帶寬問題的應用,當前版本可以調整虛擬主機和用戶帶寬限額,最高下載速度(like in mod_bandwidth),每秒訪問請求速度和最高並發訪問ip連接數(like in mod_limitipconn)。
"我告訴主機服務提供商使用mod_cband,想要限制他們用戶數據傳輸,像“每月10 Gb流量”這樣。但已有了mod_curb模塊,可以限制流量,但無法工作在虛擬主機和Apache 2下,所以我寫了自己的模塊完全適合於Apache 2 API同時支援每用戶和每虛擬主機帶寬限制。"(此段翻譯自官方網站)
FreeBSD ports path and pkg-descr info
/usr/ports/www/mod_cband
mod_cband is an Apache 2 module provided to solve the problem of limiting virtualhosts bandwidth usage. When the configured virtualhost’s transfer limit is exceeded, mod_cband will redirect all further requests to a location specified in the configuration file.
好了,說道這裡我想這個模塊的精髓之處在於完美的支援Apache 2並實現了原有兩個模塊的全部功能(2in1)且支援每用戶和每虛擬主機帶寬限制。這在進行web平台應用與整合之時給我們提供了又一易用的方法。準備動手吧﹗文中實例與系統平台均基於freebsd6.1平台。
提示︰
在進行實際操作之前請確保你的ports tree已經同步到當前版本。具體方法請參考http://cnsnap.cn.freebsd.org/doc ... ok/ports-using.html,關於freebsd和apache2的安裝本文不予介紹,同時假定你已經安裝並配置了所需環境。
安裝︰
#cd /usr/ports/www/mod_cband
#make install clean
安裝結束後末尾輸出︰
chmod 755 /usr/local/libexec/apache2/mod_cband.so
[activating module `cband’ in /usr/local/etc/apache2/httpd.conf]
===> Registering installation for mod_cband-0.9.7.3
此時cband_module已經自動添加到你的httpd.conf檔案中並開啟了。
LoadModule cband_module libexec/apache2/mod_cband.so
至此mod_cband安裝已經完成,讓我們繼續後面的操作。之前說mod_cband易用是相對的,主要是看你如何配置讓他為你所用。一些基礎配置還是很容易完成,但是要發揮它的強大和靈活配置還是要好好看看documentation,充分理解良好駕馭。不 嗦了,下面看看如何進行基本配置和使用並觀測實際效果。以我這個blog為實例,看看基本情況︰
DocumentRoot “/other/blog/wordpress”
ServerName blog.citygrit.cn
allow from all
Options +Indexes
# 100MB virtualhost bandwidth limit
CBandLimit 100M
# Maximal 1024kbps speed for this virtualhost
# Maximal 10 requests per second for this virtualhost
# Maximal 30 open connections for this virtualhost
CBandSpeed 1024 10 30
# Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client
CBandRemoteSpeed 10kb/s 3 2
# a period of time after which the scoreboard will be cleared (4 weeks)
CBandPeriod 4W
#Then you can access the status page with a URL like:http://server_name/cband-status
SetHandler cband-status
#Then you can access the status page with a URL like:http://server_name/cband-status-me
SetHandler cband-status-me
為了便於理解將上面內容裡與mod_cband相關設定予以說明,(約定“#”為註釋標記)。
# 100MB virtualhost bandwidth limit
CBandLimit 100M
限制虛擬主機總訪問帶寬為100Mb。
# Maximal 1024kbps speed for this virtualhost
# Maximal 10 requests per second for this virtualhost
# Maximal 30 open connections for this virtualhost
CBandSpeed 1024 10 30
限制此虛擬主機最高訪問速度1024kbps
限制此虛擬主機每秒最高接受請求數10個
限制此虛擬主機最高並發連接30個
# Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client
CBandRemoteSpeed 10kb/s 3 2
限制來自遠端訪問速度10kB每秒,3個請求每秒,2個連接。
# a period of time after which the scoreboard will be cleared (4 weeks)
CBandPeriod 4W
設定多久對所記錄的全局訪問帶寬進行重設(清零)。
4W=4 weeks 4周(一個月)
#Then you can access the status page with a URL like:http://server_name/cband-status
SetHandler cband-status
開啟了mod_cband的實時監測功能,可以透過http://server_name/cband-status進行直觀的觀測。(全局監測)
#Then you can access the status page with a URL like:http://server_name/cband-status-me
SetHandler cband-status-me
開啟了mod_cband的實時監測功能,可以透過http://server_name/cband-status-me進行直觀的觀測。(單一監測)
透過上文簡單介紹了mod_cband在freebsd平台下與apache2進行整合及基本配置,整個過程屬於理論結合實際操作並得以真實應用,保證其可實施性但不承諾由於其他原因造成的配置與使用問題。如果希望詳細了解mod_cband的更加強大的功能和進階配置請訪問其網站。本文中部分實例參考了官方網站和Manage Apache Download Speed And Traffic Limits With mod_cband這裡的文章。
通告︰本文系作者原創,並未抄襲互聯網及其他已發表的類似文章。文中所引用
系官方網站實例及說明。歡迎轉載但請注明出處已示對作者勞動成果的尊重,謝謝。如果您發現文中的表述有誤請聯絡我,我會及時做出修正。(但不包括由於系統平台及應用軟體發生變化而產生的問題)
|