Marius van Witzenburg We fight for our survival, we fight!

28Mar/100

How to limit the bandwidth of Apache with mod_bw on FreeBSD

Posted by mariusvw

First you have to install mod_bw:

cd /usr/ports/www/mod_bw
make install

Then open your httpd.conf and locate

#LoadModule bw_module          libexec/apache22/mod_bw.so

Remove the comment like this:

LoadModule bw_module libexec/apache22/mod_bw.so

Then you can add the following to your VirtualHost or global configuration to limit a directory speed, in my case I want to limit the band files where we host our demo materials width a limit of 50kb/s.

1
2
3
4
5
6
7
<directory /home/mariusvw/public_html/band>
    <ifmodule mod_bw.c>
        BandWidthModule On
        ForceBandWidthModule On
        Bandwidth all 50000
    </ifmodule>
</directory>

This is an example how you can globally limit all the traffic of your Apache installation.

1
2
3
4
5
<ifmodule mod_bw.c>
    BandWidthModule On
    ForceBandWidthModule On
    Bandwidth all 50000
</ifmodule>

For more info on this you can open the readme, which is located at:

/usr/local/share/doc/mod_bw/mod_bw.txt