|
|||||||||
|
|||||||||
|
|
Công Cụ | Xếp Bài |
30-07-2009, 11:42 AM | #1 | ||||||||||||||||||||||||||||||||||||||||||||
Guest
Trả Lời: n/a
|
Quản lý tốc độ download và giới hạn băng thông cho Apache bằng mod_Cband
Quản lý tốc độ download và giới hạn băng thông cho Apache bằng mod_Cband
Version 1.0 Author: Falko Timme Theo howtoforge.com In this tutorial I will describe how to install and configure mod_cband on an Apache2 web server. mod_cband is an Apache 2 module which provides bandwidth quota and throttling. It solves the problem of limiting users' and virtualhosts' bandwidth usage. The current version can set virtualhosts' and users' bandwidth quotas, maximal download speed, requests-per-second speed and the maximal number of simultanous IP connections. mod_cband can be used by hosting companies, which would like to limit data transfer for their users, such as "10 GB of traffic per month". In the first two chapters I will show how to install mod_cband on Debian Sarge and on Fedora Core 5 (the 64-bit version), and in the third chapter I will describe how to configure Apache for mod_cband which is independent from the distribution you're using. Please note: mod_cband is an Apache2 module, it does not work with Apache 1.3.x! I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you! 1 Installation On Debian Sarge In order to compile mod_cband, we must have apxs2 installed. We can achieve that by doing this: apt-get install apache2-prefork-dev Next we download and install mod_cband like this: [/php] cd /tmp wget http://cband.linux.pl/download/mod-cband-0.9.7.4.tgz tar xzvf mod-cband-0.9.7.4.tgz cd mod-cband-0.9.7.4 ./configure make make install [php] The make install command should have added the mod_cband module to /etc/apache2/httpd.conf. Run
Finallly restart Apache: /etc/init.d/apache2 restart The mod_cband installation is now finished. 2 Installation On Fedora Core 5 In order to compile mod_cband, we must have apxs installed. We can achieve that by doing this: yum install httpd-devel Next we download and install mod_cband like this: cd /tmp wget http://cband.linux.pl/download/mod-cband-0.9.7.4.tgz tar xzvf mod-cband-0.9.7.4.tgz cd mod-cband-0.9.7.4 ./configure make make install The make install command should have added the mod_cband module to /etc/httpd/conf/httpd.conf. Run vi /etc/httpd/conf/httpd.conf and check if you find a line like this:
Finallly restart Apache: /etc/init.d/httpd restart The mod_cband installation is now finished. 3 Apache Configuration You can find all configuration directives on mod_cband's documentation page http://cband.linux.pl/documentation; I will describe the most important ones here. In this chapter I assume we have a web site www.example.com on the IP address 1.2.3.4 with the document root /var/www and the following vhost configuration:
Starting httpd: [Mon May 29 18:05:33 2006] [warn] Invalid command 'CBandSpeed', undefined virtualhost name You can use the following units in the mod_cband directives: Transfer speeds:
Debian: vi /etc/apache2/apache2.conf Fedora: vi /etc/httpd/conf/httpd.conf
Debian:
Now let's say we want to limit the download speed. We can do it like this:
The CBandRemoteSpeed is like the CBandSpeed directive, but it sets limits for any individual user (as compared to the overall settings made by CBandSpeed). After your changes, you must restart Apache: Debian: /etc/init.d/apache2 restart Fedora: /etc/init.d/httpd restart 3.2 Configure Traffic Limits In the next example we want to give our vhost www.example.com a traffic limit of 100MB per month, and if that limit is exceeded, we want to limit the download speed to 128kbps, max. 5 requests per second and max. 15 open connections:
The next example is pretty similar, but now we don't want the speed to be limited if the traffic is exceeded, no, we get more restrictive and deliver a 503 status page instead:
After your changes, you must restart Apache: Debian: /etc/init.d/apache2 restart Fedora: /etc/init.d/httpd restart Of course, you are free to combine the directives of chapter 3.1 and 3.2 in any way you like. 4 Status Page To view the current bandwidth limits, usages, users, scoreboards, add the following Location lines to the vhost configuration:
5 Links tham khảo
|
||||||||||||||||||||||||||||||||||||||||||||
Công Cụ | |
Xếp Bài | |
|
|