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