By enabling ‘mod_bw’ module in apache we can control bandwidth in the server for a domain. When you find a domain using bandwidth via apache service and it need to be controlled within a certain limit and on basics of files , we can use mod_bw module in apache.
How to restrict number of simultaneous connections per vhost/dir and limit the bandwidth for files on vhost/dir
Below are steps for installation and configuration settings:-
1) Check apache version
/usr/local/apache/bin/httpd -v
Server version: Apache/2.2.14 (Unix)
Server built: Dec 3 2009 06:58:06
Cpanel::Easy::Apache v3.2.0 rev4899
2) cd /usr/src
3) wget http://ivn.cl/files/source/mod_bw-0.92.tgz // downloading the module
4) tar zxf mod_bw-0.92.tgz
5) cd mod_bw
6) cat mod_bw.txt | more // checking the basic configuration settings.
7) /usr/local/apache/bin/apxs -i -a -c mod_bw.c // adding the module to apache using apxs
8) cat mod_bw.txt | perl -pe ‘s:^:# :g’ > /usr/local/apache/conf/mod_bw.conf // removing the commented lines making it the configuration file to mod_bw.conf
9) In /usr/local/apache/conf/mod_bw.conf check whether the following line are enabled.
==================================
LoadModule bw_module modules/mod_bw.so
<location /modbw>
Order deny,allow
Deny from all
Allow from 127.0.0.1
SetHandler modbw-handler
</location>
==================================
10) In apache conf :: /usr/local/apache/conf/httpd.conf make sure both the below lines are enabled.
============================================
LoadModule bwlimited_module modules/mod_bwlimited.so
Include “/usr/local/apache/conf/mod_bw.conf”
============================================
11) In apache conf :: /usr/local/apache/conf/httpd.conf under the concerned domain vhost entry add ::
=========================================================================
Include “/usr/local/apache/conf/userdata/std/2/sl20696/domainname.com/mod_bw.conf”
=========================================================================
12) In file :: /usr/local/apache/conf/userdata/std/2/sl20696/domainname.com/mod_bw.conf add ::
=========================================================================
#BandWidthModule On
#ForceBandWidthModule On
#LargeFileLimit * 1 1
# 1 KB File 1 byte/s
# Limit every user to a max of 100Kb/s on a vhost :
BandwidthModule On
ForceBandWidthModule On
Bandwidth all 100000
MinBandwidth all -1
=========================================================================
13) Restart apache gracefully using command :: /etc/init.d/httpd graceful
If you require help, contact SupportPRO Server Admin


