root/cherokee/trunk/doc/config_virtual_servers.txt

Revision 2466, 16.1 kB (checked in by taher, 1 week ago)

--

Line 
1 == link:index.html[Index] -> link:config.html[Configuration]
2
3 Virtual Server
4 --------------
5
6 'Virtual Server' is an abstraction mechanism that allows you to define
7 a custom number of parameters and rules that have to be applied to one
8 or more domains.
9
10 In a Cherokee server there must be at least one virtual server named
11 default, and there is no maximum number. It is important to know that
12 this server cannot be deleted.
13
14 When the server receives a request it will try to match the domain
15 name specified in the virtual server that should handle it. In case no
16 virtual server matches the request, default will be used.
17
18 Three main options are accessible through this menu:
19
20 . Virtual Server List
21
22 . Add new Virtual Server
23
24 . Clone Virtual Server
25
26 *Cloning a Virtual Server* is simply a matter of selecting a target name
27 and a source virtual server currently present. Every setting will be
28 duplicated. From then onwards changes applied to any of them, be it
29 the original or the copied Virtual Servers, will only apply to the
30 implicated one. This is a great way to set up complex domains,
31 since you can use the existing ones as templates to be refined with
32 further work.
33
34 *To add a new Virtual Server* you have to enter the server name and a
35 valid Document Root directory.
36
37 image::media/images/admin_vserver.png[Virtual server]
38
39 --
40 - *Document Root*
41
42 This directive sets the directory from which Cherokee will serve
43 files. The set of rules is checked from the highest to the lowest
44 possible priority. Once a rule is matched, the server appends the path
45 from the requested URL to the document root to make the path to the
46 document. If it is a directory, this information is used. If other
47 rules apply to a parent directory, those are applied as well without
48 overwriting the original behavior:
49
50 ----
51         http://www.example.com/index.html refers to /var/www/index.html
52 ----
53
54 This might seem complicated but it's actually simple to
55 understand. For example suppose you had a directory called /secret
56 that was protected with authentication, and there was also a rule with
57 higher priority for /secret/cgi that only specified to use the CGI
58 handler. Under these circumstances, if a request was received for
59 /secret/cgi/something then the CGI handler would be taken and it would
60 inherit the authentication specified for /secret.
61
62
63 - *Name*
64
65 Name is an alias. The domain names handled by the virtual server
66 should be specified later in the virtual server details page.
67
68 --
69
70 The *Virtual Server List* is by far the most interesting of these
71 three main options. It gives an overview of the existing virtual
72 servers, and allows to configure in detail every possible setting.
73
74 image::media/images/admin_vserver_vserver.png[Virtual server overview]
75
76 A detailed explanation of every tab follows.
77
78 [[basics]]
79 Basics
80 ~~~~~~
81
82 --
83 - *Virtual Server nickname*
84
85 The name that will be used to identify the virtual server.
86
87 - *Document Root*
88
89 Path to use as root directory for the virtual server.
90
91
92 - *Directory Indexes*
93
94 The DirectoryIndex directive sets the list of resources to look for
95 when the client requests an index of the directory by specifying a /
96 at the end of the directory name. Several URLs may be given, in which
97 case the server will return the first one that it finds. If none of
98 the resources exist, the server will reply according to the handler
99 behavior.
100
101
102 Note that the documents do not need to be relative to the directory:
103
104 ----
105         index.html,index.txt,/cgi-bin/index.pl
106 ----
107
108 would cause the CGI script /cgi-bin/index.pl to be executed if neither
109 index.html nor index.txt existed in a directory.
110
111 There is a special case in which the directory index entry starts with
112 a slash. For example, /cgi-bin/index.pl. In that case, it will use it
113 as the object accessible under that public address of the same virtual
114 server, so it will take care about the possible configuration of the
115 /cgi-bin/ directory and/or the pl extension.
116
117
118 - *Keep-alive*
119
120 This flag is enabled by default. It is used to enable or disable
121 Keep-alive connections on a per-virtual-server basis. Keeping
122 persisting connections has dramatic effects both in speed, but very
123 high traffic loads can suffer because less connections are available
124 for any given moment.
125
126 --
127
128 [[domain_names]]
129 Domain names
130 ~~~~~~~~~~~~
131
132 This section allows to define the list of domains that the virtual
133 server implements.
134
135 It can accept either FQDN (Fully Qualified Domain Names) or wild
136 card entries.
137
138 For instance::
139 +
140 ----
141           example.com
142         *.example.org
143 ----
144
145 Note that you should probably keep in mind the way this list is
146 interpreted in order to avoid future problems. Whenever Cherokee
147 recieves a request for a specific domain, it evaluates the `Domain
148 list` of every defined virtual host in the order defined by the
149 priorities of such hosts. When it finds a match, it stops the
150 evaluation and starts matching the specific rules from that virtual
151 host to send the apropriate response.
152
153 If no domain name matches the request, Cherokee re-evaluates the list
154 of virtual hosts trying to match the request against the `Nicknames`,
155 also using the priorities defined by the virtual host order.
156
157 Only after failing both with the domain names and the nicknames will
158 Cherokee issue the failure.
159
160 [[behavior]]
161 Behavior
162 ~~~~~~~~
163
164 This sections allows to define a set of rules to define how the server
165 should handle the different requests. A summary of the existing rules is
166 presented, containig several fields of information:
167
168   . *Target*: web target of the rule, be it a path, a file type, etc.
169
170   . *Type*: Rule type. These will be explained in the following
171     paragraphs.
172
173   . *Handler*: The handler that manages the requests that match this
174     rule. Read on for further details.
175
176   . *Auth*: Indicates if authentication is used for this rule. This
177     can be set up through the link:config_virtual_servers_rule.html[Rule
178     Entry] menu.
179
180   . *Enc*: Indicates if any encoding is applied to the rule.
181
182   . *Exp*: Indicates if expiration headers are configured for the rule.
183
184   . *Final*: If this flag is present it means that no other rules will
185     be applied after this one, even if the request also matches other
186     rules with lower priority.
187
188 These rules can be defined based on the directory that the request
189 targets, the extension of the file that it is requesting, or a regular
190 expression that may match the request. This is the list of available
191 rule types:
192
193   * **Directory**: The entry Directory encloses a group of directives which will
194     apply only to the named directory and sub-directories of that directory.
195
196   * **Extensions**: The entry Extensions doesn't care about directories, it will
197     just look for the extension of the object requested.
198
199   * **Regular Expressions**: The Request entry provides a powerful way to apply
200     custom options to requests. It is a complement for the Directory and Extension
201     entries. Basically, there are two differences between them:
202
203     - It uses regular expressions to define the requests in which the configuration
204       will be applied.
205
206     - These entries are able to use the connection parameters (both pathinfo
207       and query string). In this way it is possible to set rules based on
208       parameter values.
209
210   * **Header**: This type of rule is used to modify the behavior in
211       response to the contents of HTTP headers. A regular expression
212       is needed to match against. This kind of rule can be used to
213       provide alternative contents to a specific type of users. For
214       example, it can check if the HTTP referrer header refferences
215       specific domains to allow or deny the delivery of the requested
216       information.
217
218   * **File Exists**: This type of rule will only be applied if a
219       certain file (or a file among a list of provided file names) is
220       present. An I/O cache specific setting for the rule can be
221       configured in the `Rule` tab. If enabled, it will speed up the
222       file detection during the rule evaluation. This improves
223       performance but is not recommended when the directory contents
224       change dynamically. This type of rule can also be used to match
225       any file. For example, it can be configured to serve static
226       files and fall through to another rule if the HTTP request is
227       for a resource of dynamic nature.
228
229   * **HTTP method**: These rules are applied whenever the selected HTTP
230       method is used. You can configure these to respond to a request
231       of type GET, POST, HEAD, PUT, OPTIONS, DELETE, TRACE, CONNECT,
232       COPY, LOCK, MKCOL, MOVE, NOTIFY, POLL, PROPFIND, PROPPATCH,
233       SEARCH, SUBSCRIBE, UNLOCK or UNSUBSCRIBE.
234
235   * **GeoIP**: If GeoIP support is present, this type of rules can be
236       added. The GeoIP library has to be present at build time for
237       this to happen. If enabled, specific behavior can be offered
238       depending on the country of origin of the requests to the web
239       server. Note that the country is determined by matching the IPs
240       to the actual list of countries handled by the library, so the
241       usage of proxies on the user side will render this resolution
242       mechanism inaccurate. An initial country must be added to the
243       rule, and more selections can be added in further steps.
244
245 It is very important to know that these rules are prioritized. The
246 higher its priority is, the sooner they are checked. You could
247 think of a network routing table, it is quite similar. You can set the
248 relative priorities among the rules by simply dragging and dropping
249 them in the desired position (if you click on the rule name, you will be
250 redirected to the rule's configuration options; if you click anywhere
251 else, you will be able to drag and drop it into the desired position).
252
253 image::media/images/admin_behaviour.png[Virtual server]
254
255 Each of these behavior rules must specify which is the handler that
256 the server should use to reply to the requests that match the rule.
257 Handlers are the modules that generate the information with which the
258 server responds a client's request. By default Cherokee provides a
259 number of them:
260
261
262 **********************************************************************
263 - link:modules_handlers_common.html[common] - **List & Send**
264 +
265 Combines both `Static Content` and `Only listing` handlers
266 functionality to behave similarly to common web servers, it will
267 display directory listings when a directory is requested and serve the
268 requested files.
269
270 - link:modules_handlers_file.html[Static Content] - **Static Content**
271 +
272 This is the file handler and it serves files straight from the
273 file system.
274
275 - link:modules_handlers_dirlist.html[dirlist] - **Only listing**:
276 +
277 Displays a directory content list when a directory is requested,
278 but it does not allow to download any content.
279
280 - link:modules_handlers_redir.html[redir] - **Redirection**
281 +
282 Perform simple and/or complex redirections using regexes.
283
284 - link:modules_handlers_cgi.html[cgi] - **CGI Execution**
285 +
286 Executes CGI programs.
287
288 - link:modules_handlers_fcgi.html[fcgi] - **FastCGI Server Support**
289 +
290 Communicates with FastCGI servers.
291
292 - link:modules_handlers_scgi.html[scgi] - **SCGI Server Support**
293 +
294 Communicates with SCGI servers.
295
296 - link:modules_handlers_server_info.html[Server Info] - **Server
297   Info**
298 +
299 Provide some configurable information about the server.
300
301 - link:modules_handlers_mirror.html[Generic balancer] - **Generic
302   balancer**
303 +
304 Select one of the available mechanisms to distribute the load (locally
305 or remotely).
306
307 - link:modules_handlers_admin.html[Remote Administration] - **Remote
308   Administration**
309 +
310 Implements an administration interface to work with
311 link:bundle_cherokee-tweak.html[cherokee-tweak].
312 **********************************************************************
313
314
315 The selection of any one of the rule targets will offer new
316 configuration options through the
317 link:config_virtual_servers_rule.html[Rule Entry] menu.
318
319 Each of the mentioned handlers can be fine-tuned through that
320 menu. Refer to each handler's documentation if you are interested in
321 the available settings.
322
323 [NOTE]
324 It is quite easy to fully specify a virtual server's behavior having
325 just some notions of Cherokee's way of working. However, there might
326 be some corner cases where Cherokee will behave in a manner that could
327 not seem obvious at first. Every doubt can be easily cleared by simple
328 understanding in full detail the way a rule is applied. For instance
329 lets suppose there is an `Extension` type rule configured to handle
330 PHP files. If a request is made for
331 `http://example.com/index.php/what/ever`, this rule *WOULD NOT* be
332 applied at first because the request doesn't end with the appropriate
333 extension: it has some adittional path information. However, if there
334 is a `Default` rule configured that is managed by the `List and Send`
335 handler, things would work. This is because the `Default` rule would
336 catch any unmatched requests, and the `List and Send` handler would
337 notice the PATHINFO part of the request. It would then split the
338 request in two parts, separating the PHP file from the appended
339 information, and would then evaluate once more the list of rules. This
340 time the request would end in `.php` and thus it would match the
341 `Extension` rule meant to handle PHP files.
342
343 [[personal_webs]]
344 Personal Webs
345 ~~~~~~~~~~~~~
346
347 This options allows to setup the name of a subdirectory inside the
348 users' home directory that will be used as document root for personal
349 web content. For instance, if `/foo` was specified, a user `bar` could
350 publish the content of ~/foo at the relative URL /~bar
351 This option is disabled if the 'Directory name' field is empty.
352
353
354 [[error_handler]]
355 Error Handler
356 ~~~~~~~~~~~~~
357
358 Several mechanisms exist to handle errors.
359
360 . Default errors
361
362 . Custom redirections
363
364 . Closest match
365
366 Using the 'Custom redirections' error handler we can easily redirect
367 errors to a custom path or website.
368
369 image::media/images/admin_vserver_errors.png[Virtual server]
370
371 The 'Closest match' error handler should never fail to deliver
372 something. If a requested resource is not available, the closest match
373 will be sent. The only exception to this is when nothing at all is at
374 Cherokee's disposal, in which case a standard http error is sent.
375
376
377 [[logging]]
378 Logging
379 ~~~~~~~
380
381 The link:modules_loggers.html[loggers] are a type of Cherokee modules
382 to write the server log information using different destinations
383 and/or formats:
384
385
386     * Destination: File, syslog, program execution and standard error output.
387
388     * Format: Combined (Apache compatible), NCSA or W3C
389
390 If a virtual server doesn't have a logger set up it will not log anything.
391
392 image::media/images/admin_vserver_loggers.png[Virtual server]
393
394 By default Cherokee ships three loggers implementing three different
395 logging formats:
396
397 --
398 - combined - link:modules_loggers_combined.html[Combined Log Format]
399
400 Logging using the Apache log format. It is the `de facto standard` nowadays.
401
402 - ncsa - link:modules_loggers_ncsa.html[NCSA Log Format]
403
404 Logging using the NCSA log format.
405
406 - w3c - link:modules_loggers_w3c.html[W3C Log Format]
407
408 Logging using the W3C log format.
409 --
410
411
412 [[security]]
413 Security
414 ~~~~~~~~
415
416 The virtual server must be configured with the path to the certificate
417 before using secure connections (https). There is a document which
418 might help to generate SSL link:cookbook_ssl.html[keys]
419
420 Cherokee fully supports the usage of different certificates for each
421 virtual server in a given host, be it using SNI as defined in
422 link:http://www.rfc-archive.org/getrfc.php?rfc=3546[RFC 3546] or by
423 elegantly respinning the secure handshake. Check the
424 link:other_goodies.html#ssl-vhosts[SSL Virtual Hosts] information for
425 more details.
426
427 If you want HTTPS to work, you must remember this:
428
429 . Providing the PEM-encoded files is mandatory for both `Certificate`
430   and `Certificate key` fields. Providing the `CA List` is optional.
431
432 . If you have several virtual servers, the `Security` section must be
433   configured for every one of them. At the moment you cannot have some
434   with HTTPS and some without. This makes sense, since by enabling the
435   feature in any one of them you are opening the HTTPS port in your
436   host, and receiving HTTPS requests for a virtual server that does
437   not provide the service would not be handled in a coherente
438   manner. None of the alternatives is very elegant in design: falling
439   back to HTTP, issuing an error that is likely to restart the HTTPS
440   hanshake, etc. This behavior, however, might change in the future
441   depending on the popularity of any proposed mechanisms.
Note: See TracBrowser for help on using the browser.