关于mod_cband的两篇文章

mod_cband真是难找啊, http://cband.linux.pl 这个几乎都没上去过,现在我用的是这个地方下载的 http://www.sfr-fresh.com/unix/privat/mod-cband-0.9.7.5.tgz 详细的可以查看 http://www.sfr-fresh.com/unix/privat/mod-cband-0.9.7.5.tgz/

第一篇
mod_cband to the Rescue
原文地址 :
http://www.montanalinux.org/mod_cband.html
The problem: A webserver with a lot of files that are to bepublic... and the public is downloading too much, too fast, toooften... in what seems to be a malicious fashion... especially sinceeveryone seems to be using multi-threaded download accelerators.Solution: mod_cband
Read more for a better explanation of the problem and the steps needed to install mod_cband.
Client Side
What is a multi-threaded download accelerator? If you or someone you know is a Microsoft Windows user, perhaps you have heard of FlashGet. For Linux, there is aget.Just what do these programs do? Let's imagine that you want to downloadone or more .iso images of the latest version of your favorite Linuxdistribution. You've found a website that has the images you arelooking for. With a multi-threaded download accelerator you candownload faster by making multiple (often 10-20), simultaneousconnections to the server with each connection being a chunk of thefile being downloaded.
Server Side
Here's what it looks like from the webserver's perspective:

221.0.97.17 - - [24/Dec/2006:04:21:27 -0700] "GET/windows/eclipse-SDK-3.2.1-win32.zip HTTP/1.1" 206 91040039"http://img.cs.montana.edu/windows/" "Mozilla/4.0 (compatible; MSIE6.0; Windows NT 5.1)"
221.0.97.17 - - [24/Dec/2006:04:21:59 -0700] "GET/windows/eclipse-SDK-3.2.1-win32.zip HTTP/1.1" 206 90999383"http://img.cs.montana.edu/windows/" "Mozilla/4.0 (compatible; MSIE6.0; Windows NT 5.1)"
221.0.97.17 - - [24/Dec/2006:04:21:09 -0700] "GET/windows/eclipse-SDK-3.2.1-win32.zip HTTP/1.1" 206 3958262"http://img.cs.montana.edu/windows/" "Mozilla/4.0 (compatible; MSIE6.0; Windows NT 5.1)"

I've only shown three entries... but in reality, there are 10-20simultaneous connections. Depending on how big the target file is andwhat size the client makes the chunks, there can be hundreds of logentries for a single downloaded file. If there are 10 hostsdownloading, that translates to 100-200 connections with a separatehttpd process servicing each of them. That is a lot of system resourcesand it is going to be a lot of bandwidth too.
Notice the 206 result code. If you see a lot of those in your log,you are getting hit by download accelerators. Here's what 206 means:

[indent]206 - Partial Content
A status code of 206 is a response to a request for part of a document.This is used by advanced caching tools, when a user agent requests onlya small part of a page, and just that section is returned.
[/indent]The machine I was having a problem with was really handling the loadjust fine. In fact, I didn't even notice anything out of the ordinary.I happen to run monit on the server in question. Not to go off on too much of a tangent, monitis a really handy application which can be configured to watch thedesired server applications and take certain actions if certainthresholds are met. Every couple of days, I was getting emails from monit telling me that it had restarted apache because it had reached the configured max number of processes which I had set to 100.
All of those connections totaled up can be a significant chunk ofbandwidth. That was the real problem... all of the bandwidth themachine was handing out continuously to the outside world. I setup theserver to be an httpd based file server mostly for machines on the LANso I could access all of the Linux .isos as well as run various distrorepositories for doing software installs and updates. It was intendedto save bandwidth since all of my lab machines would do everything overthe LAN rather than having to download from the Internet. I also wantto be able to access everything from off the LAN.
The Goal
Sure, I could password protect everything but I wanted it to be apublic resource... but now the public was really abusing the machine.Surely there must be a way to set limits with apache to :

  1. Limit the number of simultaneous connections per client
  2. Limit the amount of bandwidth a client can consume
  3. Limit how much a client can download over a given period
  4. Limit the amount of bandwidth the server will commit to off LAN downloads
  5. Differentiate between clients on the LAN and those off such that limits do not apply (or a different set of limits apply)
The apache 1.x series had mod_throttle but it had since been abandoned and was not compatible with the apache 2.x series. After a little bit of searching, I learned about mod_cband. Here is a slightly modified description of mod_cband taken from mod_cband site:

[indent]mod_cband is an Apache 2 moduleprovided to solve the problem of limiting users' and virtualhosts'bandwidth usage. The current versions can set virtualhosts' and users'bandwidth quotas, maximal download speed (like in mod_bandwidth), requests-per-second speed and the maximal number of simultanous IP connections (like in mod_limitipconn)mod_cband is especially handy for use byhosting companies which would like to limit data transfer for theirusers, such as "10 Gb of traffic per month". There already was mod_curb module, which can limit data transfers, but it doesn't work with virtualhosts and Apache 2.
[/indent]What follows isn't intended to be a HOWTO, as it is not indepth enough, but it will serve as an introduction.
Installing mod_cband
Download the LATEST source for mod_cband. At the time of writing, it was 0.9.7.5.
wget http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz
Before you try to compile mod_cband, make sure httpd-devel is installed. I'm working with CentOS machines (some even inside of an OpenVZ VPS) and I didn't have httpd-devel installed... nor did I have a compiler... so I just did the following:
yum install httpd-devel
yum did its job by figuring out all of the dependecies,downloading everything and installing it. In my particular instance, ittranslated into about 12 packages totalling approximately 15MB whichtook about 1-2 minutes.
Extract mod-cband-0.9.7.5.tgz wherever you want (I like /usr/src). cd into the directory where the source is and do the following:

./configure
make
make install

The whole process only took about a minute. The make install part even modified the /etc/httpd/conf/httpd.conf such that apache would load mod_cband. Before I restart apache though, I'll make a few more changes to its config.
After mod_cband was installed, I removed httpd-develand all of the dependencies that were installed with it... as I don'tlike to have a compiler on a webserver... as that can be used byhackers to compile their own kits if they find a way to exploit apache or some bad PHP code. The contents of /var/log/yum.log comes in handy for reversing things. :)
Configuring mod_cband
mod_cband does everything from a Virtual Host perspective... so if your apacheisn't running any virtual hosts at all, you'll need to configure atleast one... which would act a the default site. Most of theconfiguration for mod_cband is done within the container but there are some settings that are global and outside ofthe virtualhost stuff. Insert the following somewhere in your config:

CBandScoreFlushPeriod 1
CBandRandomPulse On

Here's what my virtual host container for the server in question looks like:

ServerName example.com
ServerAdmin root@localhost
DocumentRoot /var/www/html
CBandScoreboard /var/www/scoreboard
CBandClassRemoteSpeed lan_class 1024kb/s 50 100
CBandRemoteSpeed 25kb/s 3 3

SetHandler cband-status

Please note that I make reference to lan_class which is a global definition so it is contained outside of the virtual host container and looks like this:

CBandClassDst 10.0/16

You can define as many classes as you like if you have the desire.After a class is defined, you may refer to it in a virtual hostcontainer.
I'm not going to bother to explain what each mod_cband configuration directive means. That is what the documentation is for... and it does a much better job than I could. To summarize, lan_class is a mask for all of the IP addresses for all of the machines on our LAN. The CBandClassRemoteSpeed and CBandRemoteSpeed specify limits for the max bandwidth, number of requests per second, and number of connections.
Remember, whenever you change the apache config, restart httpd for the change to take affect. The section specifics a URL that can be used to get to the mod_cband status page which you can browse to to see all kinds of status and running totals.
Here's what it looks like:
640,496
You should be able to get a glimpse of some of the stuff you can do with mod_cband as well as imagine what monitoring features it gives you with the status page.
Conclusion
mod_cband did everything I wanted it to do, was easy toinstall and configure and just works. So far as features go, I've onlyscratched the surface with my needs... as it offers a ton of otherfeatures that are well suited to hosting companies who want to putlimits on the bandwidth their virtual hosts use. If you have the needor desire, give it a try and let us know how your experience went.

第二篇

Apache + mod-cband 설치하기!!!
原文地址 : http://sakura.zzabu.net/tt/107
http://www.montanalinux.org/mod_cband.html
OS : CentOS 4.4 Server
glibc-2.3.4-2.36
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8)
ltmain.sh (GNU libtool) 1.5.6 (1.1220.2.95 2004/04/11 05:50:42)
준비할 것...
- Apache-2.2.4 ( http://httpd.apache.org/ )
- mod-cband-0.9.7.5 ( http://cband.linux.pl/ )
=> 위 버전은 2007.08.01 일 기준...
일단 mod-cband 는 Apache 2.x 에서 트래픽의 양과 속도를 제어할 수 있게 해주는 모듈이다.
상당히 간편한 설정방법과 나름 괜찮은 퍼포먼스를 보여주는듯 .. 여러군데서 이용하는것 같다.
(믿거나 말거나 ....어쨌건 별 문제 없으니 많이들 쓰는거겠지 ㅡㅡ;;;;...
사실 많이 쓰는지도 의문이다 ..orz....훗~ 어짜피 막쓰는 건데!!! ;ㅂ; )
아파치 설치에 대해선 굳이 논하지 않겠다 -_-;;
일단 Apache 를 설치 하되 DSO 모듈을 이용할 수 있게 --enable-so 주고 설치하면 되겠씀돠 ...
(설치 방법은 -_- .....꼭 해야만 하나?? SRPM 으로 깔건 뭘 쓰건 알아서 깔....)
일단 Apache 의 설치가 끝나고 나면 궁극의 mod-cband 의 설치를 할 차례다.
mod-cband 의 설치 메뉴얼은 정말 간단명료하게 나와있다.
$ wget http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz
$ tar xzvf mod-cband-0.9.7.5.tgz
$ cd mod-cband-0.9.7.5

$ ./configure
$ make
$ make install

여기서 빨간색으로 칠해진 부분에 주목!
여기에 옵션이 추가 되야 하는데 ..
설치된 apxs 까지의 경로를 입력해줘야 하는데
예를 들자면.
apxs 가 /usr/foobar/apache/bin/ 에 위치한다고 할때
다음과 같이 옵션을 추가 한다.
$ ./configure --with-apxs=/usr/foobar/apache/bin/apxs
이렇게 옵션을 주고 'make' 한방 때려주면 빌드는 끝..
하지만 다음 단계로 넘어가서 'make install' 을 치면 오류가 발생한다.
Warning! dlname not found in /usr/foobar/apache/modules/mod_cband.la.
Assuming installing a .so rather than a libtool archive.

CentOS 4.3 이 깔린 서버에서도 테스트 해봤지만 동일한 오류가 발생된다.
무슨 일일까 ㅡㅡ 고민을 하면서 무려 6시간을 보냈다...
여튼 고민을 포기하고 걍 -_- 모듈을 생성해보자 쓰랴!~ 했다.
gcc -shared -Wl,-soname,mod_cband.so.1 -o mod_cband.so mod_cband.o
.......
앙탈지게 안나왔던 그 -_- 동적모듈이 다소곳이~ 생성 되어있을 것이다.
$ ls -al
-rwxr-xr-x 1 root root 151449 Aug 3 19:54 mod_cband.so
기쁘지 아니 한가!
생성된 파일을 설치된 Apache 의 modules 디렉토리에 밀어 넣고~
다음을 httpd.conf 에 추가.!!
LoadModule cband_module modules/mod_cband.so

대충 여태한 뻘짓을 다시 정리하면 ..
$ wget http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz
$ tar xzvf mod-cband-0.9.7.5.tgz
$ cd mod-cband-0.9.7.5
$ ./configure --with-apxs=[apxs PATH]
$ make
$ cd src
$ gcc -shared -Wl,-soname,mod_cband.so.1 -o mod_cband.so mod_cband.o
$ cp -p mod_cband.so /usr/foobar/apache/modules/

무엇이 더 필요한가!!?
설정 방법!!!! 은 다음기회에 ( --);;;;
혹은 참조 할만한 URL 을 -_- 곧 올리겠쓰랴~ =3=3=3
참조
Apache : http://httpd.apache.org
mod-cband : http://cband.linux.pl

评论

继续补充

这个项目应该是停止了
然后相关的分域名停了
最后的一次更新
http://www.linux.pl/?id=projekt&show=193

urpmq apache-mod_cband

$ LC_ALL=C rpm -qpi apache-mod_cband-0.9.7.5-5mdv2009.0.i586.rpm
Name : apache-mod_cband Relocations: (not relocatable)
Version : 0.9.7.5 Vendor: Mandriva
Release : 5mdv2009.0 Build Date: Fri Jun 6 02:19:25 2008
Install Date: (not installed) Build Host: n3.mandriva.com
Group : System/Servers Source RPM: apache-mod_cband-0.9.7.5-5mdv2009.0.src.rpm
Size : 114438 License: GPL
Signature : DSA/SHA1, Fri Jun 6 02:52:18 2008, Key ID dd684d7a26752624
Packager : Oden Eriksson
URL : http://cband.linux.pl/
Summary : Apache 2 Bandwidth Quota Module
Description :
mod_cband is an Apache 2 module provided to solve the problem of
limiting users' and 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.

能打开 http://cband.linux.pl/ 吗

能打开 http://cband.linux.pl/

不能哦

-_-|||

天,还有韩文

在服务器上体验了么?

服务器一直用的就是他啊

服务器一直用的就是他啊
韩文也是文嘛,参考文献