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.



Installation



  • 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
    wget http://dembol.org/downloads/cband/mod-cband-0.9.7.5.tgz

  • Untar the file
    tar -xzf mod-cband-0.9.7.5.tgz

  • Enter newly created directory
    cd mod-cband-0.9.7.5

  • Add -lm to the APXS OPTS in Makefile.in like so:
    APXS_OPTS=-lm -Wc,-Wall -Wc,-DDST_CLASS=@DST_CLASS@

  • Configure and install
    ./configure
    make
    make install

  • Restart Apache
    /etc/apache2/restart



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

Configuration



  • 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>
    <Location /cband-status-me>
    SetHandler cband-status-me
    </Location>

  • 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/domain.com.scoreboard
    </IfModule>

  • 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:
    http://server/cband-status?xml



Security


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



Credits


http://blog.lael.be/290
http://dembol.org/mod_cband
http://pessetto.com/question2answer/index.php?qa=3&qa_1=why-does-mod_cband-have-a-truncf-symbol-undefined
http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling
http://www.uno-code.com/?q=node/64
http://www.sourcefiles.org/Internet/WebServers/Modules/Bandwidth/mod-cband-0.9.7.2.tgz.shtml
http://httpd.apache.org/docs/2.0/howto/auth.html

Comments

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

    ReplyDelete

Post a Comment

Popular posts from this blog

AngularJs: User friendly date display with AngularJs and MomentJs

Nerd Tree: A File Explorer with Mac Vim

Getting started with Grails functional tests using Geb + Spock