apache: enable php 7.4 support
[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 val web_ipv6 = ipv6_of_node (web_node_to_node web_node);
7
8 var WebPlaces = [web_place_default web_node];
9
10 val 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
24 val web = \ host -> \\ config : Vhost -> begin
25 n <- DefaultWebNode;
26 webAt n host with config end;
27 end;
28
29 val 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 ipv6));
36
37 vhost host where
38 WebPlaces = [web_place web_node ip ipv6]
39 with
40 config
41 end
42 end;
43
44 val 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
57 config; (* config is included in case of directives like
58 serverAliasDefault. https rewrite should override all
59 others since it matches first. *)
60 end;
61 else
62 webAt n host where
63 SSL = no_ssl;
64 with config end;
65 end;
66 end;
67
68 val addDefaultAlias = begin
69 mailbox <- Mailbox;
70 source <- DefaultAliasSource;
71 aliasPrim source (addressTarget mailbox)
72 end;
73
74 val addWww = begin
75 web "www" with
76 serverAliasDefault;
77 www : [Vhost] <- WWW;
78 www
79 end
80 end;
81
82 val dom =
83 \ d : (your_domain) ->
84 \\ config : Domain ->
85 domain d with
86 dns (dnsNS "ns1.hcoop.net");
87 dns (dnsNS "ns2.hcoop.net");
88
89 user_web_node <- DefaultWebNode;
90
91 defa : bool <- DefaultA;
92 if defa then
93 dns (dnsA default (ip_of_node (web_node_to_node user_web_node)));
94 dns (dnsAAAA default (ipv6_of_node (web_node_to_node user_web_node)))
95 else
96 Skip
97 end;
98
99 hmail : bool <- HandleMail;
100 if hmail then
101 handleMail
102 else
103 Skip
104 end;
105
106 amx : bool <- AddMX;
107 if amx then
108 dns (dnsMX 1 "mail.hcoop.net");
109 else
110 Skip
111 end;
112
113 createWWW : bool <- CreateWWW;
114 if createWWW then
115 addWww
116 else
117 Skip
118 end;
119
120 defAl : bool <- DefaultAlias;
121 if defAl then
122 addDefaultAlias
123 else
124 Skip
125 end;
126
127 config
128 end;
129
130 val nameserver = \host -> dns (dnsNS host);
131 val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
132 val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
133 val dnsMail = \num -> \host -> dns (dnsMX num host);
134 val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
135 val dnsDefault = \to -> dns (dnsA default to);
136 val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
137 val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
138 val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
139
140 val dnsWildcardIP = \to -> dns (dnsA wildcard to);
141
142 val addDefaultSPF = dnsDefaultText "v=spf1 mx -all";