Controlling your visitors/users bandwidth usage and speed using mod_cband

Again, I’m using my beloved Debian 6 squeeze distribution to test this tutorial.
What is mod_cband? Directly taken from the one that maintain this piece of work:

mod_cband is an Apache 2 module provided 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)

I recommend you to install this module into your server if your site providing download or stream service. Benefit after installing this module is: justice for all. For you as server owner: you can control the bandwidth usage and limiting your user’s download/stream speed, keep your server’s memory usage in control. For users: high availability server, no users dominate the bandwidth alone.

OK, let’s start:
install needed package (you need to compile mod_cband by yourself)

apt-get install apache2-prefork-dev make

download and extract mod_cband

tar xzf mod-cband-

EDIT: it seems that site is not hosting mod-cband anymore, you can download mod-cband form my site instead:

go inside mod-cband directory and do ./configure

cd mod-cband-

fixing Makefile; without doing this trick, you will get error message when trying to restart Apache2 afterwards. This is the error messages:

apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/cband.load: Cannot load /usr/lib/apache2/modules/ into server: /usr/lib/apache2/modules/ undefined symbol: truncf
Action ‘configtest’ failed.
The Apache error log may have more information.

edit Makefile produced by ./configure before. add “-lm ” after “APXS_OPTS=” and before “-Wc” on line 12. See screenshot:

cband Makefile

Watch for line #12

save it and then do “make&&make install

make&&make install

restart apache2

service apache2 restart

This isn’t enough. Now, configure your virtual host to use mod_cband. This just example virtual host configuration that I use:



	DocumentRoot /var/www/mp32u

	ErrorLog ${APACHE_LOG_DIR}/mp32u.error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/mp32u.access.log combined

	CBandRemoteSpeed 102400kb/s 4 5   # speed limit, number of request per second and max. number of connections
		SetHandler cband-status  # whenever is accessed, bandwidth statistics will be shown

For more extensive and descriptive options, head to mod_cband documentation page

Example result:

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackbacks and Pingbacks: