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