hcoop: remove mccarthy and navajos from domtool control
[hcoop/domtool2.git] / lib / easy_domain.dtl
1 {{The most common kinds of domain configuration}}
2
3 val web_node : (web_node) = "shelob";
4 val default_node : (node) = web_node_to_node web_node;
5 val web_ip = ip_of_node (web_node_to_node web_node);
6
7 var WebPlaces = [web_place_default web_node];
8
9 val webAt =
10 \ n : (web_node) ->
11 \ host : (host) ->
12 \\ config : Vhost -> begin
13 dns (dnsA (literal host) (ip_of_node (web_node_to_node n)));
14
15 vhost host where
16 WebPlaces = [web_place_default n]
17 with
18 config
19 end
20 end;
21
22 val web = \ host -> \\ config : Vhost -> begin
23 n <- DefaultWebNode;
24 webAt n host with config end;
25 end;
26
27 val webAtIp =
28 \ ip : (your_ip) ->
29 \ host : (host) ->
30 \\ config : Vhost -> begin
31 dns (dnsA (literal host) (your_ip_to_ip ip));
32
33 vhost host where
34 WebPlaces = [web_place web_node ip]
35 with
36 config
37 end
38 end;
39
40 val webSsl = \ host -> \ certFile -> \\ config : Vhost -> begin
41 n <- DefaultWebNode;
42 webAt n host where
43 SSL = certFile;
44 with config end;
45
46 force_ssl <- ForceSSL;
47 if force_ssl then
48 webAt n host where
49 SSL = no_ssl;
50 with
51 rewriteRule "^(.*)$" "https://%{HTTP_HOST}$1" [redirect];
52 end;
53 else
54 webAt n host where
55 SSL = no_ssl;
56 with config end;
57 end;
58 end;
59
60 val addDefaultAlias = begin
61 mailbox <- Mailbox;
62 source <- DefaultAliasSource;
63 aliasPrim source (addressTarget mailbox)
64 end;
65
66 val addWww = begin
67 web "www" with
68 serverAliasDefault;
69 www : [Vhost] <- WWW;
70 www
71 end
72 end;
73
74 val dom =
75 \ d : (your_domain) ->
76 \\ config : Domain ->
77 domain d with
78 dns (dnsNS "ns1.hcoop.net");
79 dns (dnsNS "ns2.hcoop.net");
80
81 user_web_node <- DefaultWebNode;
82
83 defa : bool <- DefaultA;
84 if defa then
85 dns (dnsA default (ip_of_node (web_node_to_node user_web_node)))
86 else
87 Skip
88 end;
89
90 hmail : bool <- HandleMail;
91 if hmail then
92 handleMail
93 else
94 Skip
95 end;
96
97 amx : bool <- AddMX;
98 if amx then
99 dns (dnsMX 1 "mail.hcoop.net");
100 else
101 Skip
102 end;
103
104 createWWW : bool <- CreateWWW;
105 if createWWW then
106 addWww
107 else
108 Skip
109 end;
110
111 defAl : bool <- DefaultAlias;
112 if defAl then
113 addDefaultAlias
114 else
115 Skip
116 end;
117
118 config
119 end;
120
121 val nameserver = \host -> dns (dnsNS host);
122 val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
123 val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
124 val dnsMail = \num -> \host -> dns (dnsMX num host);
125 val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
126 val dnsDefault = \to -> dns (dnsA default to);
127 val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
128 val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
129 val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
130
131 val dnsWildcardIP = \to -> dns (dnsA wildcard to);
132
133 val addDefaultSPF = dnsDefaultText "v=spf1 mx -all";