test
[hcoop/zz_old/ikiwiki] / DomTool / Examples.mdwn
1 Here are some example configuration files for DomTool, our distributed configuration management system.
2
3 [[TableOfContents()]]
4
5 = Domains =
6
7 == The Model T ==
8
9 If you just want to declare your domain with a `www.yourdomain` virtual host serving out of `~/public_html/` and all mail forwarded to your mailbox, use:
10 {{{dom "yourdomain" with
11 end;}}}
12
13 == Upgraded Model T ==
14
15 If you like everything `dom` gives you but want to add additional configuration, include it between `with`..`end`. For instance, to add an extra web virtual host `other`:
16 {{{dom "yourdomain" with
17 web "other" with
18 (* More configuration could go here *)
19 end;
20 end;}}}
21
22 == Attack of the Model T Clones ==
23
24 We can take the Model T and use it with some alternate names for the domain we're configuring.
25 {{{dom "yourdomain" where
26 Aliases = ["yourotherdomain", "yourotherotherdomain"]
27 with
28 end;}}}
29 A single Apache virtual host is created, answering to multiple names. Other configuration is duplicated like you had entered it in a separate `dom` block for each alias.
30
31 == The Do-It-Yourself ==
32
33 The lowest-level way of configuring a domain is the `domain` directive, which does nothing but set up basic DNS parameters and provide a space for including further directives:
34 {{{domain "yourdomain" with
35 (* Your directives here *)
36 end;}}}
37
38 = DNS =
39
40 Here's a tour through the available DNS features.
41
42 {{{domain "yourdomain" with
43 nameserver "ns1.hcoop.net";
44 nameserver "ns3.hcoop.net";
45 (* Specify two DNS servers that are authoritative for yourdomain *)
46
47 dnsIP "host" "1.2.3.4";
48 (* Add a mapping from host.yourdomain to IP address 1.2.3.4 *)
49
50 dnsMail 23 "mail.yourdomain";
51 (* Register mail.yourdomain as an SMTP handler for yourdomain, with priority 23 *)
52
53 dnsAlias "hcoop" "hcoop.net";
54 (* Add an alias such that hcoop.yourdomain resolves to the same thing as hcoop.net *)
55
56 dnsIP "dynamic" "5.6.7.8" where
57 TTL = 100
58 end;
59 (* Add an IP mapping with an abnormally low time-to-live of 100 *)
60 end;}}}
61
62 == Keeping DNS elsewhere ==
63
64 This example shows how to configure mail handling for a domain that is primarily hosted off of HCoop:
65
66 {{{domain "yourdomain" where
67 DNS = noDns
68 with
69 handleMail;
70 end;}}}
71
72 = Mail =
73
74 {{{domain "yourdomain" with
75 handleMail;
76 (* HCoop should provide relaying for yourdomain *)
77
78 emailAlias "user1" "user1@gmail.com";
79 (* Forward mail from user1@yourdomain to user1@gmail.com *)
80
81 emailAlias "user2" "me";
82 (* Forward mail from user2@yourdomain to HCoop user me *)
83
84 aliasMulti "pals" ["pal1@yahoo.com", "pal2@prodigy.com", "pal3"];
85 (* Forward mail from pals@yorudomain to pal1@yahoo.com, pal2@prodigy.com, and HCoop user pal3 *)
86
87 aliasDrop "spamtrap";
88 (* Silently drop all mail to spamtrap@yourdomain *)
89
90 defaultAlias "me";
91 (* Send all yourdomain mail that doesn't match some local user or other special rule to user me *)
92
93 catchAllAlias "me";
94 (* Send all yourdomain mail, period, to user me *)
95 end;}}}
96
97 = Apache =
98
99 == The Model T ==
100
101 {{{domain "yourdomain" with
102 web "www" with
103 (* This is a web host found at www.yourdomain. *)
104 end;
105 end;}}}
106
107 Note that the `web` directive also adds the right DNS mapping for your virtual host.
108
109 == The Do-It-Yourself ==
110
111 {{{domain "yourdomain" with
112 vhost "www" with
113 end;
114 end;}}}
115
116 This one doesn't add any DNS mappings.
117
118 == Using a nonstandard web server ==
119
120 {{{domain "yourdomain" with
121 web "www" where
122 WebNodes = ["fyodor"]
123 with
124 end;
125 end;}}}
126
127 == Bucking all the trends ==
128
129 {{{domain "yourdomain" with
130 web "www" where
131 DocumentRoot = home "private_html";
132 User = "me_web";
133 Group = "me_web";
134 SSL = use_cert "/home/me/mycert.pem"
135 with
136 end;
137 end;}}}
138
139 `home "private_html"` builds the full path to subdirectory `private_html` of your home directory.
140
141 == Basic URL handling ==
142
143 {{{domain "yourdomain" with
144 web "www" with
145 alias "/doc" "/usr/local/doc";
146 (* Serve all URIs beginning in /doc out of directory /usr/local/doc *)
147
148 scriptAlias "/my-script" "/var/cgi/a-program";
149 (* Handle requests for /my-script by calling the CGI program /var/cgi/a-program.
150 The example here uses a file, but scriptAlias directive can also alias CGI
151 directories, as you'd expect: scriptAlias "/location/" "/directory/" *)
152
153 errorDocument "404" "not_found.html";
154 (* Handle HTTP error code 404 by sending file not_found.html *)
155 end;
156 end;}}}
157
158 == Location-specific configuration ==
159
160 {{{domain "yourdomain" with
161 web "www" with
162 location "/private" with
163 errorDocument "404" "not_found_private.html";
164 end;
165 (* When in the /private tree of URI-space, handle 404s with not_found_private.html *)
166
167 directory "/usr/local/doc" with
168 errorDocument "404" "not_found_doc.html";
169 end;
170 (* When looking for a file in real directory /usr/local/doc, handle 404s with not_found_doc.html *)
171 end;
172 end;}}}
173
174 == Server aliases ==
175
176 {{{domain "yourdomain" with
177 web "www" with
178 serverAliasHost "www2.yourdomain";
179 serverAliasHost "www.otherdomain";
180 (* www2.yourdomain and www.otherdomain are alternate names for this vhost *)
181
182 serverAlias "www3";
183 (* Short form for an alternate name within the current domain *)
184
185 serverAliasDefault;
186 (* Make this virtual host answer to yourdomain, with no extra hostname needed in front. *)
187 end;
188 end;}}}
189
190 Note that you must have domtool configuration rights to all domains you name with `serverAlias`.
191
192 == Directory options ==
193
194
195 {{{domain "yourdomain" with
196 web "www" with
197 options [execCGI, indexes];
198 (* Use exactly the Apache options execCGI and indexes by default for this vhost *)
199
200 set_options [includesNOEXEC];
201 (* Add the option includesNOEXEC, leaving the others alone *)
202
203 unset_options [indexes];
204 (* Change our mind about including indexes *)
205
206 directoryIndex ["index.html", "index.php", "index.txt"];
207 (* When looking for the default file to serve for a directory, consider these possibilities in order *)
208
209 action "image/gif" "/cgi-bin/images.cgi";
210 (* Run /cgi-bin/images.cgi to serve images *)
211
212 addDefaultCharset "utf-8";
213 (* Use the UTF-8 character set by default *)
214
215 location "/prefix" with
216 forceType "text/plain";
217 (* Serve all files in this location as plain text *)
218
219 forceTypeOff;
220 (* Change our mind about that! *)
221
222 (* All the other directives mentioned above can be used in locations, too, but forceType* _must_ be in a location. *)
223 end;
224 end;
225 end;}}}
226
227 == Access control ==
228
229 {{{domain "yourdomain" with
230 vhost "www" with
231 location "/loc1" with
232 authType basic;
233 (* Use HTTP basic authentication in this location *)
234
235 authName "my domain";
236 (* Tell users that they're authenticating for "my domain" *)
237
238 authUserFile "/etc/webusers";
239 (* Look up user/password information in /etc/webusers *)
240
241 orderAllowDeny;
242 (* Access is denied by default *)
243
244 requireValidUser;
245 (* Anyone providing a valid password is allowed *)
246
247 denyFrom "badguys.evil.net";
248 (* However, anyone coming from this domain is banned *)
249
250 denyFrom "1.2";
251 (* Also ban anyone with a 1.2.*.* IP address *)
252 end;
253
254 location "/loc2";
255 authType basic;
256 authName "my other domain";
257 authUserFile "/etc/otherone";
258
259 denyFromAll;
260 (* Deny everyone by default *)
261
262 requireUser ["fred", "barney"];
263 (* Allow fred and barney in *)
264
265 requireGroup ["prehistoric"];
266 (* Also require membership in the prehistoric group *)
267 end;
268 end;
269 end}}}
270
271 == Fancy directory index generation ==
272
273 {{{domain "yourdomain" with
274 web "www" with
275 addDescription "The planet Mars" "/web/pics/mars.gif";
276 (* Describe /web/pics/mars.gif as "The planet Mars" on index pages *)
277
278 indexOptions [fancyIndexing, htmlTable, iconHeight 10, iconWidth 10];
279 (* Set some index-generation options *)
280
281 headerName "header.html";
282 (* Include header.html at the start of a directory listing *)
283
284 footerName "footer.html";
285 (* Include footer.html at the end of a directory listing *)
286 end;
287 end;}}}
288
289 == mod_rewrite ==
290
291 {{{domain "yourdomain" with
292 web "www" with
293 rewriteRule "^(.+)\.php$" "$1.sml" [];
294 (* Rewrite all URLs ending in .php to end in .sml *)
295
296 rewriteRule "/gone.html" "http://somewhere.else/there.html" [redirectWith permanent];
297 (* Redirect /gone.html to http://somewhere.else/there.html, giving an HTTP code indicating a permanent relocation *)
298
299 rewriteLogLevel 1;
300 (* Turn on some more logging for rewrite debugging in /afs/hcoop.net/usr/$USER/apache/log/$NODE/www.yourdomain/rewrite.log *)
301 end;
302 end;}}}
303
304 == mod_proxy ==
305
306 {{{domain "yourdomain" with
307 vhost "www" with
308 proxyPass "/mirror/foo/" "http://localhost:5555/";
309 (* Proxy path /mirror/foo/ to a local server with URL base http://localhost:5555/ *)
310
311 proxyPassReverse "/mirror/foo/" "http://localhost:5555/";
312 (* Adjust Location and other HTTP headers appropriately for the above proxying *)
313 end;
314 end;}}}
315
316 = Mailman =
317
318 {{{domain "yourdomain" with
319 mailmanWebHost "lists.yourdomain";
320 (* The default server for web interfaces to this domain's mailing lists is lists.yourdomain *)
321 end;}}}
322
323 = Live Examples in HCoop AFS =
324
325 * /afs/hcoop.net/user/d/do/docelic/.domtool/spinlocksolutions.com