Mod Bandwidth for Apache (Control your Website Bandwidth)

Print
User Rating: / 14
PoorBest 

Mod Bandwidth:-

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

Home Page: http://ivn.cl/files/source/mod_bw-0.8.tgz
System /. OS : CentOS 5

You will need  httpd-devel should be installed.

cd ~
wget http://ivn.cl/files/source/mod_bw-0.8.tgz
tar xzf mod_bw-0.8.tgz
cd mod_bw

apxs -i -a -c mod_bw.c
...
...
----------------------------------------------------------------------
chmod 755 /usr/lib/httpd/modules/mod_bw.so
[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/mod_bw.so

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/yourdomain.com/httpdocs
    ServerName yourdomain.com
    ServerAlias ftp.yourdomain.com www.yourdomain.com
...
...


Time to restart Apache  web service.

service httpd restart

Alhumdulillah. Done.