POSTS
apache2 限流模組 mod_cband 說明文件
Source:http://codee.pl/cband_documentation.html
Configuration
Configuration is very simple, you must write only several lines. First, you must add the following command to the main config file to load the mod_cband module:
LoadModule cband_module modules/mod_cband.so
Configuration Directives
New commands from 0.9.7.0 version:
- CBandDefaultExceededCode – the http code sent to the user when the quota is exceeded
Units accepted in various directives:
-
transfer speeds:
- kbps, Mbps, Gbps – multiples of “bits per second”, respectively: 1024, 1024*1024 and 1024*1024*1024 bps
- kb/s, Mb/s, Gb/s – multiples of “bytes per second”, respectively: 1024, 1024*1024 and 1024*1024*1024 b/s
- defaults to kbps
-
transfer quotas:
- K, M, G – multiples of bytes, respectively: 1000, 1000*1000 and 1000*1000*1000 bytes
- Ki, Mi, Gi – multiples of bytes, respectively: 1024, 1024*1024 and 1024*1024*1024 bytes
- defaults to K
-
time periods:
- S, M, H, D, W – multiples of seconds: Seconds, Minutes, Hours, Days, Weeks; respectively: 1, 60, 3600, 86400, 604800 seconds
- defaults to S
Name | CBandDefaultExceededURL |
Description |
Default URL where mod_cband should redirect all requests to the virtualhost or user when the configured transfer limit is exceeded NOTE : If you don’t specify the exceeded URL location then standard 503 Service Unavailable will be sent |
Context | Server config |
Syntax | CBandDefaultExceededURL URL |
Name | CBandDefaultExceededCode |
Description | The http code sent to the user when the configured transfer is exceeded |
Context | Server config |
Syntax | CBandDefaultExceededCode HTTP_CODE |
Example | CBandDefaultExceededCode 509 |
Name | CBandScoreFlushPeriod |
Description | Specifies a period after which the score for the virtualhost or user is written to the scoreboard file. Use this to improve mod_cband’s performance |
Default | 1 |
Context | Server config |
Syntax | CBandScoreFlushPeriod number_of_requests |
Example |
CBandScoreFlushPeriod 100 Any virtualhost’s or user’s scoreboard will be saved after 100 requests |
Name | CBandSpeed |
Description | Specifies a maximal speed for a virtualhost |
Context | |
Syntax |
CBandSpeed kbps rps max_conn
kbps – maximal transfer speed in [kMG]bps or [kMG]B/s |
Example |
CBandSpeed 1024 10 30
Specifies maximal speed 1024kbps (1024 * 1024 bits per second), maximal 10 requests per second and with a maximum of 30 open connections NOTE: This feature is available from version 0.9.6.0 |
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandRemoteSpeed</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies maximal speed for any remote client
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandRemoteSpeed<strong><em> kbps</em> <em>rps</em> <em>max_conn</em></strong></p>
<p>
kbps – maximal transfer speed in [kMG]bps or [kMG]B/s<br /> rps – maximal requests per second<br /> max_conn – maximal number of simultaneous connections</td> </tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandRemoteSpeed 20kb/s 3 3</p>
<p>
Specifies maximal speed 20kB/s (20 * 1024 bytes per second), maximal 3 requests per second and 3 open connections for any remote client
</p>
<p>
<strong>NOTE:</strong> This feature is available from version<strong> 0.9.6.1-rc2</strong></td> </tr> </tbody> </table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandClassRemoteSpeed</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies maximal speed for any remote client from some destination class
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandClassRemoteSpeed<strong><em> class_name</em> <em>kbps</em> <em>rps</em></strong></p>
<p>
class_name – name of defined destination class<br /> kbps – maximal transfer speed in kbps or kB/s<br /> rps – maximal requests per second<br /> max_conn – maximal number of simultaneous connections</td> </tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandClassDst 66.249.64/24<br /> CBandClassDst 66.249.65/24<br /> CBandClassDst 66.249.79/24</p>
<p>
CBandClassRemoteSpeed googlebot_class 20kb/s 2 3
</p>
<p>
-Specifies maximal speed 20kB/s (20 * 1024 bytes per second), maximal 2 requests per second and 3 open connections for any remote client from class googlebot_class
</p>
<p>
<strong>NOTE:</strong> This feature is available from version<strong> 0.9.6.1-rc2</strong></td> </tr> </tbody> </table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandRandomPulse</strong>
</td>
</tr>
<tr>
<td valign="top">
Description
</td>
<td>
Turns On or Off the random pulse generator for data sending<br /> Random pulse generator is a part of the speed-limiting implementation of mod_cband. This directive changes the way a connection’s speed is determined and enforced. The connections’ speeds are measured within some time period and then provided for in that period. When r.p.g. is enabled this period is chosen randomly, providing for a statisticaly saner load distribution. Disabling this causes spikes both in bandwidth and cpu usages
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
Global
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandRandomPulse<strong><em> On/Off</em></strong>
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandLimit</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies bandwidth limit for virtualhost
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandLimit<strong><em> limit</em></strong><br /> limit – bandwidth quota size, available units:<strong> K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)</strong>
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandLimit 10M<br /> Specifies 10 * 1000 * 1000 bytes bandwidth quota<br /> CBandLimit 10Mi<br /> Specifies 10 * 1024 * 1024 bytes bandwidth quota<br /> <strong>IMPORTANT NOTE</strong> : the meaning of K, M and G changed with version 0.9.6.0. Check your config
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandClassLimit</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies bandwidth limit for virtualhost’s destination class
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td>
Syntax
</td>
<td>
CBandClassLimit<strong><em> class_name</em> <em>limit</em></strong><br /> class_name – the name of defined class<br /> limit – bandwidth quota size, available units:<strong> K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)</strong><br /> <strong>IMPORTANT NOTE</strong> : the meaning of K, M and G changed with version 0.9.6.0. Check your config
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td valign="top">
<strong>CBandExceededURL</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies a URL where mod_cband should redirect all requests to a virtualhost when the configured transfer limit is exceeded<br /> <strong>NOTE</strong> : If you don’t specify the exceeded URL location then standard 503 Service Unavailable will be sent
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td>
Syntax
</td>
<td>
CBandExceededURL<strong><em> URL</em></strong>
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td valign="top">
<strong>CBandExceededSpeed</strong>
</td>
</tr>
<tr>
<td valign="top">
Description
</td>
<td>
Specifies maximal speed to which mod_cband slows down a virtualhost when the configured transfer limit is exceeded
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandExceededSpeed<strong><em> kbps</em> <em>rps</em> <em>max_conn</em></strong><br /> kbps – maximal transfer speed in kbps or kB/s<br /> rps – maximal requests per second<br /> max_conn – maximal number of simultaneous connections<br /> <strong>NOTE:</strong> This feature is available from version<strong> 0.9.6.0</strong>
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandScoreboard</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies virtualhost’s scoreboard file
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td>
Syntax
</td>
<td>
BandScoreboard<strong><em> path</em></strong><br /> <strong>NOTE:</strong> The path must be writeable for the apache-user
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandPeriod</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies a period after which a virtualhost’s usages are cleared
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandPeriod<strong><em> period</em></strong><br /> period – available units:<strong> S (seconds), M (minutes), H (hours), D (days), W (weeks)</strong>
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandPeriod 1W<br /> CBandPeriod 14D<br /> CBandPeriod 60M
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandPeriodSlice</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies the period slice length
</td>
</tr>
<tr>
<td>
Default
</td>
<td>
slice_len = limit
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandPeriodSlice<strong><em> slice_length</em></strong>
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandLimit 100G<br /> CBandPeriod 4W<br /> CBandPeriodSlice 1W</p>
<p>
A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G …</td> </tr> </tbody> </table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong></strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Define a new cband user
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
Server config
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
<strong><em> user_name</em></strong> >
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserSpeed</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies maximal speed for a cband user
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandUserSpeed<strong><em> kbps</em> <em>rps</em> <em>max_conn</em></strong><br /> kbps – maximal transfer speed in kbps or kB/s<br /> rps – maximal requests per second<br /> max_conn – maximal number of simultaneous connections
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandUserSpeed 100kb/s 10 5<br /> Specifies maximal speed 100 kB/s (100 * 1024 bytes per second), maximal 10 requests per second and 5 open connections<br /> <strong>NOTE:</strong> This feature is available from version<strong> 0.9.6.0</strong>
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserLimit</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies bandwidth limit for a cband user
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandUserLimit<strong><em> limit</em></strong><br /> limit – bandwidth quota size, available units:<strong> K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)</strong>
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandUserLimit 10M<br /> Specifies 10 * 1000 * 1000 bytes bandwidth quota<br /> CBandUserLimit 10Mi<br /> Specifies 10 * 1024 * 1024 bytes bandwidth quota<br /> <strong>IMPORTANT NOTE</strong> : the meaning of K, M and G changed with version 0.9.6.0. Check your config
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserClassLimit</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies bandwidth limit for a cband user’s destination class
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td>
Syntax
</td>
<td>
CBandUserClassLimit<strong><em> class_name</em> <em>limit</em></strong><br /> class_name – the name of defined class<br /> limit – bandwidth quota size, available units:<strong> K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)</strong><br /> <strong>IMPORTANT NOTE</strong> : the meaning of K, M and G changed with version 0.9.6.0. Check your config
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td valign="top">
<strong>CBandUserExceededURL</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies a URL where mod_cband should redirect all requests to user’s virtualhost when the configured transfer limit is exceeded<br /> <strong>NOTE</strong> : If you don’t specify the exceeded URL location then standard 503 Service Unavailable will be sent
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td>
Syntax
</td>
<td>
CBandUserExceededURL<strong><em> URL</em></strong>
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserExceededSpeed</strong>
</td>
</tr>
<tr>
<td valign="top">
Description
</td>
<td>
Specifies maximal speed to which mod_cband slows down user when the configured transfer limit is exceeded<br /> <strong>NOTE:</strong> CBandUserExceededURL must not be used if you want to only slow down user’s pages with CBandUserExceededSpeed directive
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandUserExceededSpeed<strong><em> kbps</em> <em>rps</em> <em>max_conn</em></strong><br /> kbps – maximal transfer speed in kbps or kB/s<br /> rps – maximal requests per second<br /> max_conn – maximal number of simultaneous connections<br /> <strong>NOTE:</strong> This feature is available from version<strong> 0.9.6.0</strong>
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserScoreboard</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies a user’s scoreboard file
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td>
Syntax
</td>
<td>
CBandUserScoreboard<strong><em> path</em></strong><br /> <strong>NOTE:</strong> The path must be writeable for the apache-user
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserPeriod</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies a period after which a user’s usages are cleared
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandUserPeriod<strong><em> period</em></strong><br /> period – available units:<strong> S (seconds), M (minutes), H (hours), D (days), W (weeks)</strong>
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandUserPeriod 1W<br /> CBandUserPeriod 14D<br /> CBandUserPeriod 60M
</td>
</tr>
</table>
<table class="cband_table" border="0" width="100%">
<tr>
<td width="100">
Name
</td>
<td>
<strong>CBandUserPeriodSlice</strong>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
Specifies a period slice length
</td>
</tr>
<tr>
<td>
Default
</td>
<td>
slice_len = limit
</td>
</tr>
<tr>
<td>
Context
</td>
<td>
</td>
</tr>
<tr>
<td valign="top">
Syntax
</td>
<td>
CBandUserPeriodSlice<strong><em> slice_length</em></strong>
</td>
</tr>
<tr>
<td valign="top">
Example
</td>
<td>
CBandUserLimit 100G<br /> CBandUserPeriod 4W<br /> CBandUserPeriodSlice 1W<br /> A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G …
</td>
</tr>
</table>
<h2>
<strong>Status Handler Configuration Example</strong>
</h2>
<p>
<img style="float: right;" class="lazy " src="https://blog.sd.idv.tw/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://codee.pl/images/cband/snapshot6_small.jpg" alt="" />
<noscript>
<img style="float: right;" src="http://codee.pl/images/cband/snapshot6_small.jpg" alt="" />
</noscript> To view actual bandwidth limits, usages, users, scoreboards, add the following lines into the config file:
</p>
<pre><Location /cband-status>
SetHandler cband-status </Location> <Location /cband-status-me> SetHandler cband-status-me </Location>
<p>
Then you can access the status page with a URL like:
</p>
<p>
http://server_name/cband-status<br /> http://server_name/cband-status-me
</p>
<p>
<span style="text-decoration: underline;"><strong>In versions >=0.9.5-rc1 you can also view /cband-status handler in the XML format</strong></span> :
</p>
<p>
http://server_name/cband-status?xml<br /> http://server_name/cband-status-me?xml
</p>
<h2>
<strong>Bandwidth Speed Configuration Example</strong>
</h2>
<div style="font-size: 11px;">
<pre><VirtualHost *:80>
DocumentRoot /var/www/xyz.org/
ServerName xyz.org
CustomLog /var/log/apache2/xyz.org.access combined
ErrorLog /var/log/apache2/xyz.org.access.error
RewriteEngine On
RewriteOptions inherit
# Maximal 1024kbps speed for this virtualhost
# Maximal 10 requests per second for this virtualhost
# Maximal 30 open connections for this virtualhost
<strong>CBandSpeed 1024 10 30</strong>
# Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client
<strong>CBandRemoteSpeed 10kb/s 3 2</strong>
# Maximal 20kB/s speed, 2 requests/s and 3 open connections for remote
# clients from class googlebot_class :P
<strong>CBandClassRemoteSpeed googlebot_class 20kb/s 2 3</strong>
</VirtualHost>
<h2>
<strong>Bandwidth Quota Configuration Example</strong>
</h2>
<p>
<strong>per-virtualhost bandwidth limiting configuration</strong>
</p>
<p>
Next, you may define virtualhost’s bandwidth limits, URL location and the path to scoreboard files for individual virtualhosts:
</p>
<div style="font-size: 11px;">
<pre># specify default 'bandwidth exceeded' location
CBandDefaultExceededURL http://haha.org/bandwidth_exceeded.html
<VirtualHost *:80> DocumentRoot /var/www/xyz.org/ ServerName xyz.org CustomLog /var/log/apache2/xyz.org.access combined ErrorLog /var/log/apache2/xyz.org.access.error RewriteEngine On RewriteOptions inherit
# 100MB virtualhost bandwidth limit
<strong>CBandLimit 100000</strong>
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
<strong>CBandExceededURL http://abc.org/bandwidth_exceeded.html</strong>
# virtualhost's scoreboard file
<strong>CBandScoreboard /var/run/apache2/xyz.org.scoreboard</strong>
# a period of time after which the scoreboard will be cleared (30 minutes)
# (only in >=0.9.5-rc2)
<strong>CBandPeriod 30M</strong>
</VirtualHost>
<p>
<strong>per-user bandwidth limiting configuration (only in versions >=0.9.1)</strong>
</p>
<p>
In versions >=0.9.1 you can define limits for users and assign virtualhosts to them
</p>
<div style="font-size: 11px;">
<hr />
<pre><strong># define user 'dembol'</strong>
<CBandUser dembol> # 200MB bandwidth limit for user ‘dembol’ CBandUserLimit 200000
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
<strong>CBandUserExceededURL http://abc.org/bandwidth_exceeded.html</strong>
# user's scoreboard file
<strong>CBandUserScoreboard /var/run/apache2/dembol.scoreboard</strong>
# a period of time after which the scoreboard will be cleared (5 weeks)
# (only in >=0.9.5-rc2)
<strong>CBandUserPeriod 5W</strong>
</CBandUser>
<hr />
<pre><strong># assign virtualhost 'xyz.org' to user 'dembol'</strong>
<VirtualHost *:80> ServerName xyz.org # Specify virtualhost’s owner CBandUser dembol </VirtualHost>
# assign virtualhost ‘aga.org’ to user ‘dembol’ <VirtualHost *:80> ServerName aga.org # Specify virtualhost’s owner CBandUser dembol </VirtualHost>
<p>
<strong>per-user and per-virtualhost bandwidth limiting configuration (only in versions >=0.9.1)</strong>
</p>
<p>
In versions >=0.9.1 you can also mix per-user and per-virtualhost bandwidth limiting techniques
</p>
<div style="font-size: 11px;">
<hr />
<pre><strong># define user 'dembol'</strong>
CBandUser dembol # 200MB bandwidth limit for user ‘dembol’ CBandUserLimit 200000
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
<strong>CBandUserExceededURL http://abc.org/bandwidth_exceeded.html</strong>
# user's scoreboard file
<strong>CBandUserScoreboard /var/run/apache2/dembol.scoreboard</strong>
# a period of time after which the scoreboard will be cleared (4 days)
# (only in >=0.9.5-rc2)
<strong>CBandUserPeriod 4D</strong>
</CBandUser>
<hr />
<pre><strong># assign virtualhost 'xyz.org' to user 'dembol'</strong>
<VirtualHost *:80> ServerName xyz.org # Specify virtualhost’s owner CBandUser dembol
# 100MB virtualhost bandwidth limit
<strong>CBandLimit 100000</strong>
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
<strong>CBandExceededURL http://abc.org/bandwidth_exceeded.html</strong>
# virtualhost's scoreboard file
<strong>CBandUserScoreboard /var/run/apache2/dembol.scoreboard</strong>
# a period of time after which the scoreboard will be cleared (50 minutes)
# (only in >=0.9.5-rc2)
<strong>CBandPeriod 50M</strong>
</VirtualHost>
# assign virtualhost ‘aga.org’ to user ‘dembol’ <VirtualHost *:80> ServerName aga.org # Specify virtualhost’s owner CBandUser dembol </VirtualHost>
<p>
<strong>per-destination bandwidth limiting configuration (only in >=0.9.5-rc1 versions)</strong>
</p>
<p>
In >= 0.9.5-rc1 you can limit traffic to some destination classes. The destination classes are defined by section. The limits for the classes are specified by CBandClassLimit and CBandUserClassLimit commands
</p>
<div style="font-size: 11px;">
<pre># define 'class_1'
<CBandClass class_1> CBandClassDst 217.172.231.67 CBandClassDst 127⁄8 CBandClassDst 192.168.0.0/24 CBandClassDst 10.0.0.20 </CBandClass>
define ‘class_2’
<CBandClass class_2> CBandClassDst 192.168.100.100 CBandClassDst 153.19⁄16 </CBandClass>
<CBandUser dembol>
CBandUserLimit 1000000
CBandUserExceededURL http://edns.pl/bandwidth_exceeded.html
CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard
# 500MB limit for 'class_2'
CBandUserClassLimit class_2 500000
</CBandUser>
<VirtualHost *:80> … CBandUser dembol
# 1GB limit for 'class_1'
CBandClassLimit class_1 1000000
# a period of time after which the scoreboard will be cleared (120 seconds)
# (only in >=0.9.5-rc2)
<strong>CBandPeriod 120S</strong>
</VirtualHost>
<div class="wp_plus_one_button" style="margin: 0 8px 8px 0; float:left; ">
<g:plusone href="https://blog.sd.idv.tw/archives/105" callback="wp_plus_one_handler"></g:plusone>
</div>