I have a server and running with Apache. I know that the cPanel has the bandwidth limit but the user should not exceed the normal limit of band width for a day or hour. How should I do that using Apache.

You can use mod_bw on apache2 to limit the speed of which files get uploaded. Make sure that you have installed this module in your Apache.

Check the bandwidth module installed in your apache:
#/usr/local/apache/bin/apachectl -M |grep mod_bw

Then,

Method 1:

Limit the bandwidth of the user to 250kbps
Check the config file “httpd.conf”
Go to that location.

Now create a directory with the username and domain name


/usr/local/apache/conf/userdata/std/2/USERNAME/DOMAIN.COM

eg:- username : heman and domain name: hemanth.com

/usr/local/apache/conf/userdata/std/2/heman/hemanth.com

Create a file “cp_bw_all_limit.conf” paste the contents and save and quit.

vi cp_bw_all_limit.conf
BandWidthModule On
BandWidth all 256000

BandWidthModule On
BandWidth all 256000

This will limit the user bandwidth to 250kb/s.

The reason for this customized setup beacuse if you upgrade apache or do some modification this conf will remain the same. In case of upgrade the customized settings will be erased from the http.conf.

Method 2
Limit every user to a max of 10Kb/s on a vhost :


BandwidthModule On
ForceBandWidthModule On
Bandwidth all 10240
MinBandwidth all -1
Servername
www.example.com

Limit al internal users (lan) to 1000 kb/s with a minimum of 50kb/s , and
files greater than 500kb to 50kb/s.


BandwidthModule On
ForceBandWidthModule On
Bandwidth all 1024000
MinBandwidth all 50000
LargeFileLimit * 500 50000
Servername
www.example.com

Limit avi and mpg extensions to 20kb/s.


BandwidthModule On
ForceBandWidthModule On
LargeFileLimit .avi 1 20000
LargeFileLimit .mpg 1 20000
Servername
www.example.com

Using it the “right” way, with output filter by mime type (for text)
to 5kb/s:


BandwidthModule On
AddOutputFilterByType MOD_BW text/html text/plain
Bandwidth all 5000
Servername
www.example.com

Leave a Reply