Mod Bandwidth for Apache (Control your Website Bandwidth)

User Rating: / 14

Mod Bandwidth:-

Used to limit bandwidth utilization of your normal and virtual hosts .

Home Page:
System /. OS : CentOS 5

You will need  httpd-devel should be installed.

cd ~
tar xzf mod_bw-0.8.tgz
cd mod_bw

apxs -i -a -c mod_bw.c
chmod 755 /usr/lib/httpd/modules/
[activating module `bw' in /etc/httpd/conf/httpd.conf]

You should be able to see the LoadModule command in your httpd.conf . You can restart apache at this time.

# grep bw /etc/httpd/conf/httpd.conf
LoadModule bw_module          /usr/lib/httpd/modules/

service httpd restart

In your Virtual Host section:-

I want to restrict all downloads of files larger than 500kb, to a speed of 50kb/s.

<VirtualHost *:80>
    BandwidthModule On
    ForceBandWidthModule On

    # Unlimited Bandwidth for all (except for large files, see below):-
    BandWidth all 0

    # No one should be able to open more than 5 simultaneous connections at one time :-
    MaxConnection all 5

    # Limit files greater than 500kb to 50kb/s :-
    LargeFileLimit * 500 50000

    ServerAdmin This e-mail address is being protected from spambots. You need JavaScript enabled to view it
    DocumentRoot /var/www/vhosts/

Time to restart Apache  web service.

service httpd restart

Alhumdulillah. Done.