Installing and configuring Cband for Apache2 on Ubuntu

If you need to manage bandwidth usage on Apache web server (particularly on a per virtualhost basis) CBand could be that hero you were hoping for. Below are the steps I followed to get up and running with a basic CBand setup.


  • Install additional apache libraries. Only one of these two maybe required.
    apt-get install apache2-prefork-dev
    apt-get install apache2-threaded-dev

  • Download the module

  • Untar the file
    tar -xzf mod-cband-

  • Enter newly created directory
    cd mod-cband-

  • Add -lm to the APXS OPTS in like so:

  • Configure and install
    make install

  • Restart Apache

Hopefully you should now have successfully installed Cband on your Ubuntu server.
Now let's configure it.


  • In order to improve performance of Cband, add the following to /etc/apache2/mods-available/cband.conf
    CBandScoreFlushPeriod 1
    CBandRandomPulse On

  • Add sym link in mods-enabled folder
    ln -s ../mods-available/cband.conf cband.conf

  • Make directory to store the accumulated data
    mkdir /var/www/scoreboard

  • Change ownership of directory to the apache user
    chown www-data:www-data /var/www/scoreboard/

  • Configure access to cband-status. Cband provides a status page, which you must activate via the apache configuration. It is likely you should restrict access to this page by some means. For unrestricted access to this page add the following to cband.conf
    <Location /cband-status>
    SetHandler cband-status
    <Location /cband-status-me>
    SetHandler cband-status-me

  • In your browser, navigate to http://server/cband-status and observe your new cband status page

  • Now add cband configuration for one or more virtual hosts, restart apache, and refresh your cband status page
    <IfModule mod_cband.c>
    CBandLimit 6G
    CBandPeriod 4W
    CBandPeriodSlice 1W
    CBandSpeed 500kbps 10 30
    CBandExceededSpeed 128kbps 5 15
    CBandScoreboard /var/www/scoreboard/

  • If you would like to do something more with all the data Cband is collecting you can retrieve an XML representation by using a url of the form:


You don't want to let just anyone find intimate details about a site your hosting. You need to password-protect that data!

  • One of the simplest ways to password-protect is using the http auth module of apache. To get started on this path, reopen the file /etc/apache2/mods-available/cband.conf

  • Add the following lines to both of your Location elements replacing knownSystemUser appropriately:
    AuthType Basic
    AuthName "Restricted"
    AuthUserFile /usr/local/apache/passwd/passwords
    Require user knownSystemUser

  • Now create a password for the specified user in the specified file
    mkdir -p /usr/local/apache/passwd/passwords
    htpasswd -c /usr/local/apache/passwd/passwords knownSystemUser



  1. thank you very very much bro... agian thank you very very very much... i like it..


Post a Comment

Popular posts from this blog

Android: How to change size of vector drawable image

AngularJs: User friendly date display with AngularJs and MomentJs

Nerd Tree: A File Explorer with Mac Vim