🌑

Linhost.info

Bandwidth limiting in Apache2

Serving large files from a web server can be a pain, specially if you have limited bandwidth. The ultimate goal is to offer the best service to each user, that’s why it’s a good idea to sometimes limit or throttle the available bandwidth for each user. In the Ubuntu repositories you can find the modules libapache2-mod-bw for Apache which will help you manage the the available bandwidth each user gets when downloading a file from Apache web server. This article assumes you already have a functional Apache installation Install mod_bw using apt-get.

sudo apt-get install libapache2-mod-bw

And enable the module using a2enmod bw.

sudo a2enmod bw

Now add the following to /etc/apache2/sites-available/default. The intention is to limit the bandwidth available to every user to 10Kb/s. Double the value in Bandwidth all if you wish to increase the rate.

ServerAdmin webmaster@localhost

    BandwidthModule On
    ForceBandWidthModule On
    Bandwidth all 10240
    MinBandwidth all -1

Restart Apache web server for the changes to take effect.

sudo /etc/init.d/apache restart

, — Jul 16, 2009