apache: add ipv6 support
[hcoop/domtool2.git] / lib / easy_domain.dtl
CommitLineData
6bb366c5
AC
1{{The most common kinds of domain configuration}}
2
4dffd36f 3val web_node : (web_node) = "shelob";
733d4d61 4val default_node : (node) = web_node_to_node web_node;
539abe03 5val web_ip = ip_of_node (web_node_to_node web_node);
15e529d6 6
733d4d61
CE
7var WebPlaces = [web_place_default web_node];
8
15e529d6 9val webAt =
ae272cb5
AC
10 \ n : (web_node) ->
11 \ host : (host) ->
12 \\ config : Vhost -> begin
cfedb922 13 dns (dnsA (literal host) (ip_of_node (web_node_to_node n)));
15e529d6 14
ae272cb5
AC
15 vhost host where
16 WebPlaces = [web_place_default n]
17 with
18 config
19 end
20 end;
15e529d6 21
5c8b4fb8
CE
22val web = \ host -> \\ config : Vhost -> begin
23 n <- DefaultWebNode;
24 webAt n host with config end;
25end;
6bb366c5 26
2e87719c 27val webAtIp =
ae272cb5
AC
28 \ ip : (your_ip) ->
29 \ host : (host) ->
30 \\ config : Vhost -> begin
cfedb922 31 dns (dnsA (literal host) (your_ip_to_ip ip));
2e87719c 32
ae272cb5
AC
33 vhost host where
34 WebPlaces = [web_place web_node ip]
35 with
36 config
37 end
38 end;
2e87719c 39
6052cb79
CE
40val 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;
58end;
59
a356587a 60val addDefaultAlias = begin
d4e42f2a 61 mailbox <- Mailbox;
945262dc
CE
62 source <- DefaultAliasSource;
63 aliasPrim source (addressTarget mailbox)
d4e42f2a
AC
64end;
65
66val addWww = begin
67 web "www" with
68 serverAliasDefault;
69 www : [Vhost] <- WWW;
70 www
71 end
72end;
73
a356587a 74val dom =
ae272cb5
AC
75 \ d : (your_domain) ->
76 \\ config : Domain ->
77 domain d with
78 dns (dnsNS "ns1.hcoop.net");
0c195384 79 dns (dnsNS "ns2.hcoop.net");
6bb366c5 80
5c8b4fb8
CE
81 user_web_node <- DefaultWebNode;
82
942d94ab
AC
83 defa : bool <- DefaultA;
84 if defa then
5c8b4fb8 85 dns (dnsA default (ip_of_node (web_node_to_node user_web_node)))
942d94ab
AC
86 else
87 Skip
88 end;
6eeb3bf9 89
b3cab94c
AC
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
4515633d 99 dns (dnsMX 1 "mail.hcoop.net");
b3cab94c
AC
100 else
101 Skip
102 end;
6bb366c5 103
ae272cb5
AC
104 createWWW : bool <- CreateWWW;
105 if createWWW then
106 addWww
107 else
108 Skip
109 end;
d4e42f2a 110
ae272cb5
AC
111 defAl : bool <- DefaultAlias;
112 if defAl then
113 addDefaultAlias
114 else
115 Skip
116 end;
d4e42f2a 117
ae272cb5 118 config
5c8b4fb8 119end;
6b718954 120
8c142ff5 121val nameserver = \host -> dns (dnsNS host);
cfedb922
AC
122val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
123val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
8c142ff5 124val dnsMail = \num -> \host -> dns (dnsMX num host);
cfedb922
AC
125val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
126val dnsDefault = \to -> dns (dnsA default to);
127val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
63ac3b82
AC
128val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
129val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
6b65a0a6 130
1b1021cb 131val dnsWildcardIP = \to -> dns (dnsA wildcard to);
5ea8643a
CE
132
133val addDefaultSPF = dnsDefaultText "v=spf1 mx -all";