mod_curb 1.1

mod_curb is a cumulative bandwidth limiting module for Apache.

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
GPL (GNU General Public License) 
Steve Kemp
ROOT \ Internet \ HTTP (WWW)
mod_curb is a cumulative bandwidth limiting module for Apache.

This module was written to solve the problem of limiting the bandwidth usage of a hosted website.

Several small hosting companies will happily give you a co-located box with a set data transfer limit, such as '2Gb of traffic per month'. They will charge you extortionately if you go over this limit...

I've looked around and I can't find a simple software solution to limit the data that Apache will serve, so I wrote one.

Alternative Solutions

The obvious solution is to store your files on a FTP server such as ProFTPd, and get Apache to redirect to that using mod_proxy, or something similar.

That's the only approach I could think of - things like mod_bandwidth, or mod_throttle just allow you to limit the current connections to prevent saturation - they don't keep track of the cumulative transfer over a given time period. (Yes mod_throttle does have 'Volume' limiting, but its not sufficient for my kind of limiting).


There are only a few configuration options to play with:

BandWidthExceeded The URL to redirect to if the bandwidth is exceeded.
BandWidthLimit The maximum bandwidth to allow, eg '2Gb', '650Mb'
BandWidthMonitorURL A URL which may be used to monitor in real time the current bandwidth served, eg '/mod_curb/status'.

More options should be forthcoming to vary the timeframe for which allocations are possible...


If you're running Debian, or RedHat Linux and you have got the 'apache-dev' package installed you should be able to build the module with a simple 'make -f Makefile-dev install'.

Otherwise rebuild Apache from source with something like this:

./configure --add-module=../mod-curb-1.0/mod_curb.c
--enable-shared=curb --enable-shared=status --enable-module=so

A minimal configuration will look something like this:

# Bandwidth limiting requires mod_status
LoadModule status_module libexec/
ExtendedStatus on

# Load the limiting code.
LoadModule mod_curb libexec/

# Go here if the limit is exceeded
BandWidthLimit 750Mb
BandWidthMonitorURL /bandwidth-status/


This module will only work for complete servers, it will not handle virtual servers at all. Eventually be an Apache 2.x module implementing this functionality for virtual hosts, but I see no reason to tidy/release it prior to more widespread adoption of Apache2.
Once the bandwidth limit has been reached the server will redirect all further requests to a user specified URL. (Usually a static page which says something like 'Bandwidth exhausted, return in an hour').
To reset things you must restart the server. If the bandwidth limit is a few hundred Mb a day then simply setup a cronjob to do the necessary restart.
This module requires the use of mod_status, and 'ExtendedStatus On' to function normally.

Common Problems

If you visit the status URL you've setup and the bandwidth transferred stays at '0' then you've almost certainly not enabled mod_status, or included 'ExtendedStatus On' in your configuration file...

What's New in This Release:

Fixed MIME-types bug
Right-align byte counts on the status page

Last updated on October 7th, 2007

#limit bandwidth #Apache module #URL redirect #bandwidth #limiter #Apache #module

Add your review!