linux poison RSS
linux poison Email

Setup and Configure Bandwidth Limiting Module for Apache2

mod-bw is an Apache 2 module provided to solve the problem of limiting users’ and virtual hosts’ bandwidth usage. The current versions can set virtual hosts’ and users’ bandwidth quotas, maximal download speed, requests-per-second speed and the maximal number of simultaneous IP connections.

mod-bw Features:
 * Lightweight bandwidth limiting module for Apache2
 * per-user bandwidth limiting
 * per-virtual host bandwidth limiting
 * per-destination bandwidth limiting
Limiting:
   * Bandwidth total usage (bandwidth quota)
   * Maximal download speed (bandwidth throttling)
   * Maximal requests-per-second speed
   * Maximal simultaneous IP connections
 * Support for virtual hosts
 * Support for defined users

Installing  mod-bw:
Open the terminal and type following command to install mod-bw
apt-get install libapache2-mod-bw
Now enable the module by using the a2enmod command (from terminal):
sudo a2enmod bw
Below example is showing how to place the bandwidth limit for a given virtual hosts:
<VirtualHost *:8080>
        ServerName www.abc.com
        ServerAlias www.abc.com
        DocumentRoot /var/www/abc

        # Turn bandwidth limitation on
        BandwidthModule On

        # force limitation on every request
        ForceBandWidthModule On

        # limit to 500kB/s
        Bandwidth all 504800

        # Setup custom error message
        ErrorDocument 510 /errors/maxconexceeded.html
        BandWidthError 510

        # Limit avi and mpg extensions to 20kb/s.
        LargeFileLimit .avi 1 20000
        LargeFileLimit .mpg 1 20000

</VirtualHost>
After making the changes make sure to restart/reload your Apache server.
There are many more ways to place the limit of bandwidth for more details, please do check - here



0 comments:

Post a Comment

Related Posts with Thumbnails