• Photos Photos
  • Linked In Linked In
  • Google + Google +
  • Facebook Facebook
  • Flickr Flickr
  • Vimeo Vimeo

www.gavinwill.me.uk

Photography, IT, Bikes and more.

  • Pages

    • About
    • Blog
    • Contact
    • Home
  • Archives

    • January 2013
    • September 2012
    • August 2012
    • July 2012
    • June 2012
    • May 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • December 2011
    • November 2011
  • Search:

Posts

  • View Archive

Limit Apache Bandwidth with mod_bw

Apache will normally serve a file at the maximum speed possible. I needed to rate limit an apache server to act as a fake QOS to ensure the line would not be saturated when serving large files. This is incredibly easy to do with mod_bw. First we need to install and enable mod_bw

 apt-get install libapache2-mod-bw
 a2enmod bw

apt-get install libapache2-mod-bw a2enmod bw

Then it is a simple task of specifying the limits in you virtualhost conf file.

BandWidthModule On
ForceBandWidthModule On
BandWidth 10.40.0.0/16 0
BandWidth all 1500000

BandWidthModule On ForceBandWidthModule On BandWidth 10.40.0.0/16 0 BandWidth all 1500000

The above enables the module, forces the module for all apache traffic and then finally we dont restrict the local network but restrict everyone else to 150KB/s.

Then simply restart apache

/etc/init.d/apache2 restart

/etc/init.d/apache2 restart

You can test by commenting out the line for the local network, restarting apache again and then try to download a large file and you should notice the browser is only about to download at around 150KB/s.

  • September 6, 2012
  • IT & Computing, Linux
  • 0
Cancel Reply

Copyright © 2021 www.gavinwill.me.uk.

  • LinkedIn
  • Google +
  • Facebook
  • Flickr
  • Vimeo
Back to Top