forked from maiha/mod_cband
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathINSTALL
More file actions
214 lines (153 loc) · 6.05 KB
/
INSTALL
File metadata and controls
214 lines (153 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
$Id: INSTALL,v 1.6 2006/01/28 19:36:33 dembol Exp $
mod_cband - A per-user, per-virtualhost and per-destination bandwidth
limiter for the Apache HTTP Server Version 2
INSTALLATION
============
Prerequisites
* Apache 2.0.54 - http://www.apache.org/
Other versions may work but have not been tested
Building
If you have got the apxs2 (APache eXtenSion tool) tool installed, write the following commands to build module:
$ wget http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz
$ tar xzvf mod-cband-0.9.7.5.tgz
$ cd mod-cband-0.9.7.5
$ ./configure
$ make
$ make install
Otherwise, you must rebuild your Apache from source with something like this:
configure --add-module=../mod-cband/mod_cband.c --enable-shared=cband --enable-module=so
CONFIGURATION
=============
Configuration is very simple, you must write only several
lines. First, you must add following command to the main config file
to load mod_cband module. The path to mod_cband.so depends on your
apache installation.
LoadModule cband_module modules/mod_cband.so
--------------------------------------------------------
a) per-virtualhost bandwidth limiting configuration
Next, you may define virtualhosts bandwidth limits, URL locations and
path to the scoreboard file for individual virtualhosts:
# 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
CBandLimit 100000
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
CBandExceededURL http://abc.org/bandwidth_exceeded.html
# virtualhost's scoreboard file
CBandScoreboard /var/run/apache2/xyz.org.scoreboard
# a period of time after which the scoreboard will be cleared (1 week) (only in >=0.9.5-rc2)
CBandPeriod 1W
</VirtualHost>
--------------------------------------------------------
b) per-user bandwidth limiting configuration (only in >=0.9.1 versions)
In >=0.9.1 versions you can define limits for users and assign virtualhosts to them
# define user 'dembol'
<CBandUser dembol>
# 200MB bandwidth limit for user 'dembol'
CBandUserLimit 200000
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
CBandUserExceededURL http://abc.org/bandwidth_exceeded.html
# user's scoreboard file
CBandUserScoreboard /var/run/apache2/dembol.scoreboard
# a period of time after which the scoreboard will be cleared (4 days) (only in >=0.9.5-rc2)
CBandUserPeriod 4D
</CBandUser>
# assign virtualhost 'xyz.org' to user 'dembol'
<VirtualHost *:80>
ServerName xyz.org
# Specify virtualhost owner
CBandUser dembol
</VirtualHost>
# assign virtualhost 'aga.org' to user 'dembol'
<VirtualHost *:80>
ServerName aga.org
# Specify virtualhost owner
CBandUser dembol
</VirtualHost>
--------------------------------------------------------
c) per-user and per-virtualhost bandwidth limiting configuration (only in >=0.9.1 versions)
In >=0.9.1 versions you can also mix per-user and per-virtualhost bandwidth limiting techniques
# define user 'dembol'
<CBandUser dembol>
# 200MB bandwidth limit for user 'dembol'
CBandUserLimit 200000
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
CBandUserExceededURL http://abc.org/bandwidth_exceeded.html
# user's scoreboard file
CBandUserScoreboard /var/run/apache2/dembol.scoreboard
# a period of time after which the scoreboard will be cleared (2 minutes) (only in >=0.9.5-rc2)
CBandUserPeriod 2M
</CBandUser>
# assign virtualhost 'xyz.org' to user 'dembol'
<VirtualHost *:80>
ServerName xyz.org
# Specify virtualhost owner
CBandUser dembol
# 100MB virtualhost bandwidth limit
CBandLimit 100000
# redirect to http://abc.org/bandwidth_exceeded.html
# when the limit has been reached
CBandExceededURL http://abc.org/bandwidth_exceeded.html
# virtualhost's scoreboard file
CBandScoreboard /var/run/apache2/xyz.org.scoreboard
# a period of time after which the scoreboard will be cleared (3 hours) (only in >=0.9.5-rc2)
CBandPeriod 3H
</VirtualHost>
# assign virtualhost 'aga.org' to user 'dembol'
<VirtualHost *:80>
ServerName aga.org
# Specify virtualhost owner
CBandUser dembol
</VirtualHost>
d) per-destination bandwidth limiting configuration (only in >= 0.9.5-rc1 versions)
In >= 0.9.5-rc1 you can limiting traffic to some destination classes. The destination classes
are defined by <CBandClass class_name> section. The limits for the classes are specified by
CBandClassLimit and CBandUserClassLimit commands
# 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 (30 minutes) (only in >=0.9.5-rc2)
CBandPeriod 30M
</VirtualHost>
/cband-status handler
=====================
To view actual bandwidth limits, usages, users, scoreboards, add the
following lines into the config file:
<Location /cband-status>
SetHandler cband-status
</Location>
Then you can access the status page with a URL like:
http://server_name/cband-status
In >=0.9.5-rc1 versions you can also view /cband-status handler in the XML format:
http://server_name/cband-status?xml