View Full Version : HOWTO : Mod_Bandwidth for DA
jeffery
07-23-2004, 12:29 AM
************************************
Mini-Howto on installing Mod_BandWidth
Version 2.0.5
Date : 23 July 2004
Tested on Redhat 9
************************************
Step 1 - Download mod_bandwidth
#cd /usr/local/directadmin/customapache (You may change this)
#wget ftp://ftp.cohprog.com/pub/apache/module/1.3.0/mod_bandwidth.c
Step 2 - APXS Compilation
#/usr/sbin/apxs -c ./mod_bandwidth.c -o /etc/httpd/modules/mod_bandwidth.so
Step 3 - Link Directory
#mkdir /tmp/apachebw
#mkdir /tmp/apachebw/link
#mkdir /tmp/apachebw/master
#chown -R apache:apache /tmp/apachebw
Step 4 - Modify Apache Conf
#vi /etc/httpd/conf/httpd.conf
Place those lines in whatever place you want:
<IfModule mod_bandwidth.c>
BandWidthDataDir /tmp/apachebw
BandWidthModule On
</IfModule>
Step 5 - Customize Virtual Host Limitation
You may now customize each virtual host's httpd.conf located in
/usr/local/directadmin/data/user/{username}/
by adding "BandWidthModule On" (without quotes) in each <VirtualHost>, and mod_bandwidth tag like "BandWidth" inside <Directory> tag.
Step 6 - Do a safe apache restart
#service httpd restart
OK! You may now upload a huge file (enough to test) to a dummy site that you limited to test.
:)
neorder
07-23-2004, 01:26 AM
may i know what does mod_bandwidth do and what's it's advantage over default DA bandwidth function and mod_throttle?
thanks.
jeffery
07-23-2004, 03:09 AM
mod_bandwidth can limit per user/per domain bandwidth, such as 100KB/s.
For more information, refer to their website:
http://www.cohprog.com/v3/bandwidth/intro-en.html
sander815
07-24-2004, 09:55 AM
if i compile this, and don't add any user, does apache work as normal, withoutany limits?
jeffery
07-24-2004, 10:02 AM
The module is set to be disabled unless you add
"BandWidthModule On"
:)
sander815
07-25-2004, 06:24 AM
i don't get step 5:
Step 5 - Customize Virtual Host Limitation
You may now customize each virtual host's httpd.conf located in
/usr/local/directadmin/data/user/{username}/
by adding "BandWidthModule On" (without quotes) in each <VirtualHost>, and mod_bandwidth tag like "BandWidth" inside <Directory> tag.
you mean like this:
[code]<VirtualHost 81.23.xxxx:80>
BandWidthModule On
ServerName www.xxxx.nl
ServerAlias www.xxxl dtp.fxxe.nl
ServerAdmin webmaster@xxx
DocumentRoot /home/xxx/domains/xx/public_html/dtp
ScriptAlias /cgi-bin/ /home/xxx/domains/xxxnl/public_html/$
User xxx
Group xxx
CustomLog /var/log/httpd/domains/xxx.bytes bytes
CustomLog /var/log/httpd/domains/xxx.dtp.log combined
ErrorLog /var/log/httpd/domains/xxx.nl.dtp.error.log
<Directory /home/xxxx/domains/xxx.nl/public_html/dtp>
Options +Includes -Indexes
BandWidth
php_admin_flag engine ON
php_admin_flag safe_mode OFF
</Directory>
#php_admin_value open_basedir /home/xxx/:/tmp/:/var/www/:/usr/loc$
</VirtualHost>
and where do i set f.i. 300 kb/s?
jeffery
07-25-2004, 10:30 AM
Yes.
You may set
BandWidth all 1024
where the unit of 1024 is "Bytes/s".
sander815
07-25-2004, 02:31 PM
is this step from the docs for mod_bandwidth not neccessary?:
* Add the following lines to your httpd.conf file :
LoadModule bandwidth_module libexec/mod_bandwidth.so
AddModule mod_bandwidth.c
Those directives should be placed at the begining of the list so that
the module will be given the lowest priority and be executed after others modules.
sander815
07-25-2004, 03:29 PM
so this should do it:
<VirtualHost 81.23.xxxx:80>
BandWidthModule On
ServerName www.xxxx.nl
ServerAlias www.xxxl dtp.fxxe.nl
ServerAdmin webmaster@xxx
DocumentRoot /home/xxx/domains/xx/public_html/dtp
ScriptAlias /cgi-bin/ /home/xxx/domains/xxxnl/public_html/$
User xxx
Group xxx
CustomLog /var/log/httpd/domains/xxx.bytes bytes
CustomLog /var/log/httpd/domains/xxx.dtp.log combined
ErrorLog /var/log/httpd/domains/xxx.nl.dtp.error.log
<Directory /home/xxxx/domains/xxx.nl/public_html/dtp>
Options +Includes -Indexes
BandWidth all 25600
php_admin_flag engine ON
php_admin_flag safe_mode OFF
</Directory>
#php_admin_value open_basedir /home/xxx/:/tmp/:/var/www/:/usr/loc$
</VirtualHost>
this sets the bandwidth cap to all directories under public_html? also subdomains?
jeffery
07-25-2004, 11:19 PM
Originally posted by sander815
is this step from the docs for mod_bandwidth not neccessary?:
* Add the following lines to your httpd.conf file :
LoadModule bandwidth_module libexec/mod_bandwidth.so
AddModule mod_bandwidth.c
Those directives should be placed at the begining of the list so that
the module will be given the lowest priority and be executed after others modules.
Those lines are added by DA, but they are not loaded because mod_bandwidth is not loaded.
so this should do it:
code:--------------------------------------------------------------------------------<VirtualHost 81.23.xxxx:80>
BandWidthModule On
ServerName www.xxxx.nl
ServerAlias www.xxxl dtp.fxxe.nl
ServerAdmin webmaster@xxx
DocumentRoot /home/xxx/domains/xx/public_html/dtp
ScriptAlias /cgi-bin/ /home/xxx/domains/xxxnl/public_html/$
User xxx
Group xxx
CustomLog /var/log/httpd/domains/xxx.bytes bytes
CustomLog /var/log/httpd/domains/xxx.dtp.log combined
ErrorLog /var/log/httpd/domains/xxx.nl.dtp.error.log
<Directory /home/xxxx/domains/xxx.nl/public_html/dtp>
Options +Includes -Indexes
BandWidth all 25600
php_admin_flag engine ON
php_admin_flag safe_mode OFF
</Directory>
#php_admin_value open_basedir /home/xxx/:/tmp/:/var/www/:/usr/loc$
</VirtualHost>
When you put "bandwidth" in <directory>, that means this directory and its sub-directories are limited.
sander815
07-26-2004, 02:21 AM
Originally posted by jeffery
Yes.
You may set
BandWidth all 1024
where the unit of 1024 is "Bytes/s".
its limiting indeed, on my testdomain, but it seems like i can't get more then 100 kb/s dlspeed, i am at BandWidth all 1024000, but still, 100 kb/s is max dl speed. I would like to limit at around 300 kb/s, 100 is a bit too low
jlasman
07-26-2004, 10:41 AM
What bandwidth to you seem to get for your test site when you turn limiting off?
Jeff
sander815
07-26-2004, 11:13 AM
when i put ''bandwith all 0'' i get full speed, 100%[====================================>] 29,902,848 7.70M/s ETA 00:00
when i put ''bandwith all 262144'' i get 12% [===> ] 3,660,624 88.96K/s ETA 04:48, that should be around 256 kb/s, if i calculate right. Higher numbers produce same speed of around 90 kb/s
jlasman
07-26-2004, 11:24 AM
Well, then forget my idea... it's been disproved.
Don't know.
:(
Jeff
jeffery
07-26-2004, 12:12 PM
You have to use
"BandWidthPulse"
according to the author.
But I haven't test it yet! :)
sander815
07-30-2004, 01:04 AM
any1 solved this problem?
sander815
08-02-2004, 03:02 AM
Originally posted by jeffery
You have to use
"BandWidthPulse"
according to the author.
But I haven't test it yet! :)
when do you have time to test this?
sander815
08-14-2004, 06:09 AM
finally found a working soplution:
add into the global httpd.conf:
BandWidthPulse 500000
so, like this:
<IfModule mod_bandwidth.c>
BandWidthDataDir /tmp/apachebw
BandWidthModule On
BandWidthPulse 500000
</IfModule>
that worked for me
BadSpeed
11-20-2004, 08:45 AM
I'm using this mod.
And everytime there is an update of DA, the directory in /tmp/apachebw gets deleted and I have to recreate before rerunning httpd.
Is there a way to recreate those directories after an update to avoid down time :s
Hi, please could someone update this thread, especially the following question?Originally posted by BadSpeed
everytime there is an update of DA, the directory in /tmp/apachebw gets deletedAlso, what is the meaning of "BandWidthPulse", what does its value represent, and how does the value of "BandWidthPulse" relate to the value of "BandWidth"?
TIA!
BadSpeed
12-21-2004, 05:06 AM
The pulse is the latence that use the module in order to limit the bandwidth ... from what I understand :P
For my problem I have found a way that prevent this error. Simply move those directory to a new spot ... like /apachebw
Just make sure to make the changes in your httpd.conf :P
redeye
01-18-2005, 07:51 AM
I have:
httpd.conf:
<IfDefine HAVE_BANDWIDTH>
LoadModule bandwidth_module modules/mod_bandwidth.so
</IfDefine>
<IfDefine HAVE_BANDWIDTH>
AddModule mod_bandwidth.c
</IfDefine>
<IfModule mod_bandwidth.c>
BandWidthDataDir /tmp/apachebw
BandWidthModule On
BandWidthPulse 500000
</IfModule>
/usr/local/directadmin/data/user/{username}/httpd.conf
<VirtualHost 12.34.56.78:80>
BandWidthModule On
ServerName www.xyz.com
ServerAlias www.xyz.com xyz.com
ServerAdmin webmaster@xyz.com
DocumentRoot /home/xyz/domains/xyz.com/public_html
ScriptAlias /cgi-bin/ /home/xyz/domains/xyz.com/public_html/cgi-bin/
User xyz
Group xyz
CustomLog /var/log/httpd/domains/xyz.com.bytes bytes
CustomLog /var/log/httpd/domains/xyz.com.log combined
ErrorLog /var/log/httpd/domains/xyz.com.error.log
<Directory /home/xyz/domains/xyz.com/public_html>
BandWidth all 25600
Options +Includes -Indexes
php_admin_flag engine ON
php_admin_flag safe_mode OFF
</Directory>
#php_admin_value open_basedir /home/xyz/:/tmp/:/var/www/:/usr/local/lib/php/:/etc/virtual/
</VirtualHost>
after service httpd restart i get:
Syntax error on line 13 of /usr/local/directadmin/data/users/xyz/httpd.conf:
Invalid command 'BandWidthModule', perhaps mis-spelled or defined by a module not included in the server configuration
[FAILED]
I've checked the directory:
ll /etc/httpd/modules/mod_bandwidth.so
ls: /etc/httpd/modules/mod_bandwidth.so: No such file or directory
So is it not default installed??? If so, how do I get it installed?
BadSpeed
01-18-2005, 12:31 PM
read the first port of this topic :p
redeye
01-18-2005, 02:33 PM
done that allready, and it's working. I got confused by the remarks that DA included this mod by default. :D
Thx anyhow
nbhosting
11-20-2005, 12:59 AM
Seting a value with "BandWidthPulse", will change the algorithm so that the server will always wait the same amount of time between sending packets but the size of the packets will change. The value is in microseconds. For example, if you set "BandWidthPulse 1000000" (1 sec) and the bandwidth available is of 512B, the sever will transmit 512B, wait 1 second, transmit 512B and so on.
@how@
11-20-2005, 04:09 AM
thanks, work fine :D
duock
02-24-2006, 12:20 AM
hi guy
i got a question is
is BandWidth all 25600 mean one ip bandwidth or the whole ip bandwidth?
milan
03-02-2006, 06:39 AM
no bandwidth per user
Aspegic
03-25-2006, 04:46 PM
I wish someone would write a DA plugin for mod_bandwidth, with options for:
1. install mod_bandwidth
2. uninstall mod_bandwidth
3. modify bandwidth settings for all users
4. modify bandwidth settings per user
5. list all users with their bandwidth settings
In case you're reading this jon, maybe an idea for jtbox? ;)
Alliance1911
04-20-2006, 10:12 PM
is it possible with this to have it work with a certain process? such as shoutcast, so lets say i have a shoutcast plan set got 64kbps and want to have it at that speed but also maintaining 100mbps on web browsing on the site for 1 certain account??
rusel
10-16-2006, 03:24 AM
Hi, I`ve got everything on place, mod_bandwidth.so is in modules etc, and it is loaded, but I`m getting this
Syntax error on line 12 of /usr/local/directadmin/data/users/download/httpd.conf:
Invalid command 'BandWidthModule', perhaps mis-spelled or defined by a module not included in the server configuration
master:/etc/httpd# mcedit /usr/local/directadmin/data/users/download/httpd.conf
when I add after
<VirtualHost 80.86.84.29:80>
BandWidthModule On
.... everything is set ok... I have to add <ifmodule mod_bandwidth.c> to havent errors, but then bandwidth does not work :/ have u got any ideas? apache 1.3.
works
03-20-2007, 02:10 AM
I have followed all the instructions on first post and if I place the code below in httpd.conf any where as mentioned by the author of this thread I was not able to get mod_bandwidth to work.
I have got it working on when I placed the code as below above <IfModule mod_userdir.c>
<IfModule mod_bandwidth.c>
BandWidthDataDir /tmp/apachebw
BandWidthModule On
BandWidth all 25600
</IfModule>
<IfModule mod_userdir.c>
#UserDir public_html
UserDir disabled
</IfModule>
I am not sure why, may be some conflict in order or something when placed anywhere. But placing the mod_bandwidth code as shown above worked for me.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.