mod-cband - is it working?

Discussion in 'Server Operation' started by UsagiChan, Jan 23, 2009.

  1. UsagiChan

    UsagiChan New Member

    I have a dedicated server with Fedora fc-9, apache 2.2.9 and webmin 1.441. I mainly use webmin to manage my server. I installed mod_cband using webmin and yum.

    I have a new need on my sites to make many files available for downloading. I have 1TB of bandwidth so I must be careful that my sites don't end up stopped half-way through the month because my bandwidth has been exceeded. So I moved all files for downloading into a sub-domain (http://files.mydomain.com) and installed mod_cband so I could limit the subdomain's bandwidth.

    I modified httpd.conf:

    Just under the mod area I added:
    LoadModule cband_module modules/mod_cband.so
    #
    # Cband directives:
    CBandScoreFlushPeriod 1
    CBandRandomPulse On

    And in the virtual hosts area I added:

    <VirtualHost *:80>
    ServerName files.mysite.com
    DocumentRoot /home/myfiledirectory/html
    ServerAdmin [email protected]
    CustomLog /home/myfiledirectory/access_log combined
    ErrorLog /home/myfiledirectory/error_log
    CBandSpeed 1024 10 30
    CBandRemoteSpeed 20kb/s 3 3
    CBandLimit 700G
    CBandExceededURL http://files.mysite.com/bandwidth_quota.html
    CBandScoreboard /home/myfiledirectory/scoreboard
    CBandPeriod 4W
    <Location /cband-status>
    SetHandler cband-status
    </Location>
    <Location /cband-status-me>
    SetHandler cband-status-me
    </Location>
    <Directory "/">
    Options +All
    AllowOverride All
    </Directory>
    </VirtualHost>

    I added the directory /home/myfiledirectory/scoreboard, it's owner and group being apache. I gave the directory permissions of 777.

    After this I restarted apache.

    After downloading a file, I see nothing in the directory /home/myfiledirectory/scoreboard, no new files, database or subdirectories.

    I cannot tell if cband is working. When I go to http://files.mysite.com/cband-status I get error 403, Forbidden. I am seeing this in the error log:[Thu Jan 22 01:51:14 2009] [error] [client 71.65.221.205] File does not exist: /home/myfiledirectory/html/crossdomain.xml I have never knowingly called for this file.

    later edit: The need for "crossdomain.xml" is apparently due to the fact that some of the files to be downloaded are flash files. I added the this file as per: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213

    I have checked and located mod_cband.so. It is located in /usr/lib/httpd/modules It's owner and group are root, permissions, 755, the same as the large number of other modules in that directory.

    UsagiChan
     
    Last edited: Jan 23, 2009
  2. UsagiChan

    UsagiChan New Member

    I tried http://files.mysite.com/cband-status-me. I get a screen and can see that it's working now. Still I'm confused about why I get "forbidden" for http://files.mysits.com/cband-status. What that address is supposed to show?

    In the tutorial here:
    http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling_p2
    http://www.vinacis.net/index2.php?option=com_content&do_pdf=1&id=29

    You are told to create a scoreboard directory. It is not a directory, but it's a file that has to be writable by apache. That's stated here in the docs.:
    http://www.sfr-fresh.com/unix/privat/mod-cband-0.9.7.5.tgz:a/mod-cband-0.9.7.5/doc/documentation.txt

    The scoreboard file apparently is not necessary but helps performance.

    UsagiChan
     
  3. UsagiChan

    UsagiChan New Member

    Well, I guess no one is going to answer this post.

    I found a solution to the final problem of "forbidden when asking for
    http://files.mysite.com/cband-status:

    Code:
    <Location /cband-status>
         SetHandler cband-status
         deny from all        
         AuthType Basic       
         AuthUserFile /home/mydirectory/.htpasswd
         AuthName "Restricted Area"
         require valid-user
         satisfy any
    </Location>
    By adding the lines:
    deny from all
    AuthType Basic
    AuthUserFile /home/mydirectory/.htpasswd
    AuthName "Restricted Area"
    require valid-user
    satisfy any

    I no longer get "forbidden"

    I got help on this from here: http://www.whoopis.com/howtos/apache-auth.html. It is really necessary to password protect /cband-status because there is a reset link on the page that will start the download count all over and we wouldn't want that reset available to everyone. Of course, one needs to create the password file.

    This solves the last problem, "forbidden" Perhaps it will help someone else.

    One last thing that would be nice is to be able to do the reset as a cron job, since the module has no way to account for 30, 31, 28 and 29 days in months and most hosts would count the bandwidth on a monthly basis not 4 week or 30 day basis

    UsagiChan
     
    Last edited: Jan 25, 2009

Share This Page