View Single Post
  #1 (permalink)  
Old 14-11-2006, 22:17
eUKShane eUKShane is offline
Senior System Administrator
 
Join Date: Oct 2006
Posts: 149
Thumbs up How To: Limit your customers (or free sites!) on amount of bandwidth....

How To: Limit your customers (or free sites!) on amount of bandwidth they can use daily using mod_throttle.

The Apache module, mod_throttle gives you the ability to further focus your client's bandwidth usage. Instead of giving them 30 GB/Month, how about giving them 1 GB/Day? Or 42 MB/Hour? Even 11KB/sec? You get the idea. We've all had clients than burn through their bandwidth in the first few days. Or how about a website hosting that gets 'slashdotted?'

SSH into your box and do the following:

Code:
mkdir /home/src
cd /home/src
wget www. mirrorservice.org/sites/www.ibiblio.org/gentoo/distfiles/mod_throttle312.tgz
tar zxvf mod_throttle312.tgz
cd mod_throttle-3.1.2
Need to locate apxs :

Quote:
locate apxs
Output should be :
/usr/local/apache/bin/apxs OR
/usr/sbin/apxs

Now we will have to edit Makefile :

Quote:
vi Makefile
change APXS=apxs to APXS=[APXS PATH]
Now save this file, and continue to compile..

Quote:
make
make install
Now, restart apache:

Quote:
/usr/local/apache/bin/apachectl restart
Now it's installed!

Now how to use it......?

Edit your /etc/httpd/conf/httpd.conf OR /usr/local/apache/conf/httpd.conf and locate the virtualhost entry for the website hosting you wish to throttle. Just BEFORE the < /VirtualHost > entry, insert:

Quote:
< IfModule mod_throttle.c >
ThrottlePolicy Volume 1G 1d
< /IfModule >
< Location /throttle-me >
SetHandler throttle-me
< /Location >
Note : remove the space after "<" and before ">".

The ThrottlePolicy line is the key. The first number is the amount of data and acceptable letters are G, M and K. The second number is the period and acceptable letters are m, w, d, h, and s.


Then restart Apache (service httpd restart) Now you can go to:

http://throttleddomain.com/throttle-me

And see the status of the throttle.

If you want to be able to see the status of all throttled website hostings on the server at once, go to the first virtualhost entry in your httpd.conf file (this should be the entry for your server's hostname) and add the following:

Quote:
< Location /throttle-status >
SetHandler throttle-status
< /Location >
Then restart Apache again, and you can go to http://hostname/throttle-status and see the status of all throttled website hostings.

That's all !

---------------------------------
Best Regards,
UKShane
http://www.eukhost.com
Reply With Quote