-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.config
470 lines (421 loc) · 14.8 KB
/
site.config
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
#################################################################
## This is a Wub configuration file. The file format is the
## Tcl Config file format (see: Utilities/Config.tcl).
##
## Entries in this file are organized under section headers to
## facilitate reading and understanding the contents of the file.
#################################################################
#################################################################
## The following sections configure modules that are part of the
## Wub core. Most of these parameter settings can also be set from
## the command line.
##
## Note that the these sections have names that start with an
## upper case character, which distinguishes them from domain
## specifcations
#################################################################
# Wub section contains global configuration variables
Wub {
docroot $topdir/docroot; # where to look for document root
# home [file normalize [file dirname [info script]]] ;# home of application script
# host [info hostname] ;# default home for relative paths
# application "" ;# package to require as application
# path "" ;# path - suffix to add to auto_path
# require "" ;# list of extra packages to require
# local local.tcl ;# post-init localism
# local_config 1 ;# use ${home}/local.config too
# password "" ;# account (and general) root password
}
# Shell is an optional module to permit tcl command line interaction
# via a telnet session. Please change the password if you enable it.
Shell {
load 0; # Don't start Shell by default
password PASSWORD; # define a shell login password - change this!
port 8082; # Console listening socket
}
# Httpd is the protocol module for HTTP1.1
Httpd {
max_conn 20 ;# max_conn - maximum connections per IP
no_really 30 ;# no_really - how many times to complain
;# about max_conn before taking action
retry_wait 20 ;# retry_wait - how long to advise client
;# to wait on resource exhaustion
timeout 60000 ;# timeout - ms of idle to tolerate
;# before a connection is forcibly reaped
}
# Log controls server logging
Log {
file wub.log ;# log filename for common log format logging
}
# STX markup language used in the default Wub configuration,
# and variously when we want to generate some HTML on the fly
STX {
load 1 ;# we need STX for default markup
scripting 0 ;# permit stx scripting?
}
# Nub
# Url dispatcher for Wub
Nub {
#mount /nub ;# optional nub introspection mount point
# uncomment to enable nub introspection
}
# User Agent Parser
# used to analyse the UserAgent field passed in by browsers
# it's not really safe to rely on this stuff, but if you want to
# do browser sniffing, it at least deals with the morass of half-truths
# browsers tell us (e.g. did you know IE reports that it's a version of Mozilla?)
UA {
# load 1 ;# parse user agent into $r -ua
}
# Listener module defines the HTTP network listener
# connections are established through this module, and simply passed
# into the protocol engine. This module allows you to define where
# the server should accept connections (which port, which interface, etc.)
Listener {
-port 8080 ;# HTTP listener's port
#-myaddr X ;# make listener listen on the nominated interface
}
# Https module defines the HTTPS network listener
# same as Listener, but allows you to specify TLS parameters
Https {
-port 8081 ;# HTTPS listener's port
#-myaddr X ;# make listener listen on the nominated interface
#-host X ;# host the listener thinks it's serving
-certfile server-public.pem
-keyfile server-private.pem
#-ca ca ;# the domain of the CA Certificate Authority (if any)
}
# Cache module controls server-side caching.
# Wub will cache generated content, following HTTP protocols,
# enabling you to avoid regenerating expensive content.
Cache {
#load 0 ;# turn off caching
high 100 ;# high water mark for cache
low 90 ;# low water mark for cache
maxsize 204800 ;# maximum size of object to cache
weight_age 0.02 ;# age weight for replacement
weight_hits -2.0 ;# hits weight for replacement
#mount /cache ;# mount Cache introspection URL
}
# Sscgi module supports the SCGI protocol for backends
# this enables Wub to hang off the back of another web
# server, processing requests for it.
Sscgi {
-port 0 ;# scgi disabled by default
# -port 83 ;# scgi port uncomment to enable
}
# Human - heuristic attempt to distinguish between robots and humans
# the premise is that robots don't return cookies, but humans do. YMMV.
Human {
load 0
logdir $Wub::docroot
}
#################################################################
## The remainder of this file defines how URL dispatching is to
## be performed by the server that is being configured.
##
## Resolution of a URL incident on the server is processed in a
## strict order: rewrite, redirect, auth, block, domain
## So rewrite clauses will be repeatedly applied until they have
## no effect. After that, any matching redirect will be applied,
## and processing repeated. After that, auths and blocks will
## be applied. If the URL hasn't yet been resolved, the domain
## will be applied.
##
## Note that section names are all alphanumeric lower case
## or start with a literal /
##
## Alphanumeric lowercase section names are arbitrary identifiers
## and can be chosen to be meaningful to the author. They must contain
## a 'url' element, which matches against incoming requests.
##
## Section names commencing with / are interpreted as URL fragments
## of the form /path or //host/path. These URL fragments serve to match
## incoming request URLs to the nub which handles them.
##
## A section, however named, will apply the specified nub to a request
## which matches an incoming request. Longer matches are preferred.
##
## The Wub server provides several built-in types of nub with different
## semantics.
##
## A section specifies what type of nub it represents by including an element
## block, code, domain, literal, redirect, rewrite or regsub
##
## If there is ambiguity, the presence of a 'domain' element makes the
## section a domain type nub.
##
## block - A 'block' nub blocks clients which access the URL pattern.
## A blocked client is permanently blocked, can't access the server
##
## code - A 'code' nub executes a tcl script and returns the result.
## The 'code' element value is the script.
##
## domain - A 'domain' nub associates a domain handler with a URL domain.
##
## The domain handler is a class or namespace ensemble which
## accepts a request dict and returns a result dict.
##
## The 'domain' element value specifies the TclOO class which handles
## matching requests.
##
## All other elements in the section are passed as named arguments
## to the domain class constructor.
##
## If 'domain' is a list of the form {class instance} the handler
## object will be created with the instance name given.
##
## literal - A literal nub returns a literal string.
##
## The 'literal' element value is the content to be returned to the client
## The 'mime' element value is the mime type of the literal content
##
## redirect - A redirect nub redirects one domain to another.
## The 'method' element optionally specifies one of:
## Moved, SeeOther, Found or Relocated (default Found)
## The 'redirect' element value is a literal url to which the client
## will be redirected.
## host specifies literal rewrite of redirected url's host
## port specifies literal rewrite of redirected url's port
## path specifies literal rewrite of redirected url's path
##
## if any of host,port or path is specified, the redirect url is ignored
##
## rewrite - A rewrite nub rewrites a domain path to a new path by calling
## the Tcl script given in the 'rewrite' element value.
##
## regsub - A regsub nub rewrites a domain path to a new path by invoking
## [regsub] over the 'regsub' element value.
##
## Wub provides a set of CORE domain handlers that implement
## a web services.
##
## CORE handlers
## ---------------
## File - The File domain handler provides a traditional Web
## view for filesystem hierarchies, mapping a URL suffix
## to a file system path.
##
## Icons - The Icons domain handler returns one of several
## built-in Wub icons as its response.
##
## CGI - The CGI domain handler provides a traditional CGI
## interface.
##
## Direct - The Direct domain associates a user defined TclOO class or
## namespace ensemble URL domain such that every method
## in the class whose name starts with '/' is associated
## with the corresponding URL path in the domain, and is invoked with
## all url query args are passed to that method.
##
## Mason - The Mason domain maps a URL domain onto a file-system
## hierarchy and also provides a templating and pre- and
## post- filtering of requests and responses (respectively).
##
## The Wub distribution also contains additional domain handlers
## that are production ready or are still being developed. These
## additional domain handlers and be found in the Domain directory
## under the <docroot> tree.
##
## PROD handlers
## ---------------
## About - The About domain handler returns API documentation for
## the domain handlers.
## Nub - The Nub domain handler implements an API to the
## functionallity provide by the Nub module. The Nub module
## controls the dispatch function of the Wub server and the
## API allows you to dynamically modifiy the mapping of
## URL requests to domain handlers.
## JQ - The JQ domain provides an interface to the jQuery
## (see: http://en.wikipedia.org/wiki/JQuery) cross-browser
## JavaScript library.
##
## DEVL handlers
## ---------------
## RAM - The RAM domain handler uses the URL suffix as the
## index value of a tcl array. The tcl array is accessed
## using the index value and the result is returned.
## Sticky -
## Tupler -
## Repo -
## Tie -
## Sinorca -
## Simplicio -
#################################################################
#################################################################
## The following domain definitions establish the basic server URL
## dispatching. No group 1 or 2 domain handlers are used for these
## domains. Modify these definitions to configure the basic
## capabilities of the server.
#################################################################
## the special URL 'default' determines Wub's behaviour
## when a URL can't be resolved
## NB: the default declaration is in every way equivalent to
## the domain / ... use one or the other, but not both
default {
url default
code {set r [Http NotFound $r]; <p> "[dict get $r -uri] Not Found"}
}
## find the favico icon in /images
/favico.ico {
rewrite /images/twub32.jpg
}
# the URL / redirects to /wub
/ {
redirect /wub/
}
# important to have a robots.txt
# The literal nub returns whatever content is given in its first argument as a response
# to requests for the URL. An optional second argument gives its content-type
/robots.txt {
literal "User-agent: *\nDisallow:\n"
mime text/plain
}
# Wub has its own CA.
/ca/ -loaddir [file join $Wub::topdir CA] {
domain {CA ca}
}
# block some bogus URLs
# URLs of the following forms are blocked by the server.
noexe {
block /*.exe
}
nowmv {
block /*.wmv
}
nocgi {
block /cgi-bin/
}
# /wub is handled by a Mason domain
/wub/ {
domain Mason
root $Wub::docroot
}
/icons/ {
domain Icons
}
/css/ {
domain File
root $Wub::docroot/css
expires tomorrow
}
/images/ {
domain File
root $Wub::docroot/images
expires next week
}
/scripts/ {
domain File
root $Wub::docroot/scripts
expires tomorrow
}
/html/ {
domain File
root $Wub::docroot/html
}
#//fred.com/html/ {
# domain File; # This matches the hostname, like an Apache-style virtual host...
#}
/CGI/ {
domain CGI
root $Wub::docroot/cgi
# windows tcl executor
# executors .tcl C:/Tcl/bin/base-tcl8.6-thread-win32-ix86.exe
}
/introspect/ {
domain Introspect
}
# use the build-in code domain
# The code domain evaluates its first argument as a tcl script, and returns it with the
# optional type specified by the second domain
/clock.txt {
code {clock format [clock seconds]}
mime text/plain
}
icorewrite {
# rewrite all urls of the form /*.jpg at the top level
# so they appear to be under the /images/ URL. It picks the parsed URL path
# directly from the request dict to regenerate the URL in script form.
url {^//[^/]+/[^/]+[.](jpg|gif|png)$}
rewrite {/images/[Url tail [dict get $r -path]]}
}
cssrewrite {
# rewrite all urls of the form /*.css at the top level
# so they appear under the /css/ URL, using the -regsub rewrite form, substituting
# the examined URL directly into its result using tcl regsub command.patth
url {^//[^/]+/[^/]+[.]css$}
rewrite {/css/[Url tail [dict get $r -path]]}
}
#################################################################
## The following domain definitions add functionality using the
## group 1 domain handlers. These handlers provide enable Wub
## interface documentation, a domain edit capaiblity and an AJAX
## domain.
#################################################################
# the About domain provides documentation for Wub modules and Domains
/wub/docs {
domain About
}
/jquery/ {
domain JQ
}
#################################################################
## GROUP 2
## The are experimental domain handlers
#################################################################
#/ram/ {
# domain RAM
#}
#/sticky/ {
# domain Sticky
# file ./sticky.db
# hotzone #sticky
#}
# demo the tupler domain
#/tuple/ {
# domain Tupler
# -loaddir [file join $Wub::topdir Tuple]
#}
#/repo/ {
# domain Repo
# tar 1
# upload 1
# root $Wub::docroot
#}
#/tie/ {
# domain Tie
#}
#/tiny/ {
# domain Tiny
# file $topdir/data/tiny.db
#}
#/sinorca/ {
# domain Sinorca
#}
#/simplicio/ {
# domain Simplicio
#}
#/tk/ {
# domain WubTk ;# WubTk domain
# -loaddir [file join $Wub::topdir WubTk] ;# where to find the WubTk package
# file [file join $Wub::topdir WubTk test.tk] ;# user script file
# lambda "" ;# user script
# theme_switcher 1 ;# turn on the demo theme switcher?
# #cookie wubtk ;# application cookie name
# expires "" ;# application cookie expiry
# cookiepath /mount/path ;# application cookie path - defaults to domain's url
# stylesheet "" ;# application stylesheet URL
# css {} ;# explicit CSS
# fontsize 12 ;# base font size in PX
# theme start ;# jquery UI theme
# theme_switcher 1 ;# enable UI theme switcher?
# timeout 0 ;# enable push?
# icons /icons/ ;# URL prefix for spinner
# spinner_size 20 ;# size of spinner
# #spinner_style "position: fixed; top:10px; left: 10px;" ;# css for spinner
#}
# Add a themeable SVG icon set.
#/button {
# domain Button
# -loaddir [file join $Wub::topdir Domains Button]
#}