Bandwidth & Connections Limiting: A How To Guide
I wanted to host for my brother the latest WoW patch, but at a hefty 450 MB, I didn’t want to blow all my bandwidth on it either. I am setting a limit for the download at 2.5 TB of bandwidth, and limiting it to 5mbs at 10 connections a second. My hardware is RHEL 4 running on a P4 with Plesk 8. In the guide to follow, you’ll see a few steps that wouldn’t be needed on a non-plesk system. To setup bandwidth limiting for the host, we need to be able to compile a new apache module against our system, and then install and configure it.
Step 1: The prereqs
First I needed to setup a yum repository for FC4. This can be accomplished by issuing an RPM command:
rpm -ivh http://rpm.livna.org/livna-release-4.rpm
Now that you can access the RPM packages, we need to install http-devel using yum:
yum install httpd-devel
If all went well, we can now extract, compile, and install mod_cband for apache:
cd /tmp
wget http://cband.linux.pl/download/mod-cband-0.9.7.4.tgz
tar xzvf mod-cband-0.9.7.4.tgz
cd mod-cband-0.9.7.4
./configure
make
make install
If all went well, restart apache with the new module (you can check httpd.conf to make sure the module is going to be loaded):
/etc/init.d/httpd restart
Step 2: Configuration
Here’s where the Plesk part gets annoying. We can’t just edit our vhosts file, because plesk writes over it all the time. Instead, we edit a /home/httpd/vhosts/*/subdomains/*/conf/vhost.conf file. Mine looks like this:
CBandScoreboard /var/www/scoreboard
CBandPeriod 4W
CBandDefaultExceededCode 509
CBandLimit 2500G
CBandSpeed 5000 5 10
CBandRemoteSpeed 1600 3 1
<Location /cband-status>
SetHandler cband-status
</Location>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>
What does this mean? (1) Use /var/www/scoreboard to log usage and limits (2) Reset the limit count every 4 weeks (3) Throw a 509 error when the limits are exceeded (4) Allow 2.5TB per period (5) Allow 5mbs with 5 requests a second and 10 connections at a time oeverall (6) Allow 1.6mbs with 3 requests a second and 1 connections at a time per client (7) Allow us to access a page at /cband-status to view the status.
You’ll also need to issue commands to make the scoreboard directory, and to allow apache to own it:
mkdir /var/www/scoreboard
chown apache:apache /var/www/scoreboard
Finally, Plesk requires you to inform it of your work:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=yourdomain.com
If you restart Apache now, everything should work!
/etc/init.d/httpd restart
Step 3: An Example
You can take a peek at my status page right now if you’d like. It looks a bit like this:

Update: Fixed a little formatting.
This entry was posted on Tuesday, June 20th, 2006 at 9:25 pm and is tagged with yum repository, yum yum, cband, bandwidth connections, apache cd, fc4, tar xzvf, plesk, wget, apache module, devel, rpm, step 2, step 1, scoreboard, p4, tmp, lt, tb, linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.


on August 30th, 2006 at 4:18 pm
that little ‘reset’ link on your stats page resets the bandwidth limits. Your 2500mb/mo limit keeps getting reset.
Just FYI…
on July 30th, 2008 at 8:34 am
thank you
please tell me how can i disable or uninstall cband module?