]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
4288c2f2 IB |
2 | let |
3 | www_root = "/run/current-system/webapps/_www"; | |
4 | theme_root = "/run/current-system/webapps/_theme"; | |
5 | apacheConfig = { | |
9271611c IB |
6 | cache = { |
7 | # This setting permits to ignore time-based cache for files in the | |
8 | # nix store: | |
9 | # If a client requires an If-Modified-Since from timestamp 1, then | |
10 | # this header is removed, and if the response contains a | |
11 | # too old Last-Modified tag, then it is removed too | |
12 | extraConfig = '' | |
13 | <If "%{HTTP:If-Modified-Since} =~ /01 Jan 1970 00:00:01/" > | |
14 | RequestHeader unset If-Modified-Since | |
15 | </If> | |
16 | Header unset Last-Modified "expr=%{LAST_MODIFIED} < 19991231235959" | |
17 | ''; | |
18 | }; | |
4288c2f2 IB |
19 | gzip = { |
20 | modules = [ "deflate" "filter" ]; | |
21 | extraConfig = '' | |
22 | AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript | |
23 | ''; | |
24 | }; | |
25 | macros = { | |
26 | modules = [ "macro" ]; | |
27 | }; | |
28 | stats = { | |
29 | extraConfig = '' | |
30 | <Macro Stats %{domain}> | |
31 | Alias /webstats ${config.services.webstats.dataDir}/%{domain} | |
32 | <Directory ${config.services.webstats.dataDir}/%{domain}> | |
33 | DirectoryIndex index.html | |
34 | AllowOverride None | |
35 | Require all granted | |
36 | </Directory> | |
37 | <Location /webstats> | |
38 | Use LDAPConnect | |
39 | Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu | |
40 | </Location> | |
41 | </Macro> | |
42 | ''; | |
43 | }; | |
44 | ldap = { | |
45 | modules = [ "ldap" "authnz_ldap" ]; | |
46 | extraConfig = '' | |
47 | <IfModule ldap_module> | |
48 | LDAPSharedCacheSize 500000 | |
49 | LDAPCacheEntries 1024 | |
50 | LDAPCacheTTL 600 | |
51 | LDAPOpCacheEntries 1024 | |
52 | LDAPOpCacheTTL 600 | |
53 | </IfModule> | |
54 | ||
55 | Include /var/secrets/apache-ldap | |
56 | ''; | |
57 | }; | |
58 | global = { | |
d3452fc5 IB |
59 | extraConfig = '' |
60 | ErrorDocument 500 /maintenance_immae.html | |
61 | ErrorDocument 501 /maintenance_immae.html | |
62 | ErrorDocument 502 /maintenance_immae.html | |
63 | ErrorDocument 503 /maintenance_immae.html | |
64 | ErrorDocument 504 /maintenance_immae.html | |
65 | Alias /maintenance_immae.html ${www_root}/maintenance_immae.html | |
66 | ProxyPass /maintenance_immae.html ! | |
67 | ||
68 | AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${www_root}/googleb6d69446ff4ca3e5.html | |
69 | <Directory ${www_root}> | |
70 | AllowOverride None | |
71 | Require all granted | |
72 | </Directory> | |
73 | ''; | |
4288c2f2 IB |
74 | }; |
75 | apaxy = { | |
76 | extraConfig = (pkgs.webapps.apache-theme.override { inherit theme_root; }).apacheConfig; | |
77 | }; | |
78 | http2 = { | |
79 | modules = [ "http2" ]; | |
80 | extraConfig = '' | |
81 | Protocols h2 http/1.1 | |
82 | ''; | |
83 | }; | |
84 | customLog = { | |
85 | extraConfig = '' | |
494d0718 | 86 | LogFormat "%{Host}i:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost |
4288c2f2 IB |
87 | ''; |
88 | }; | |
89 | }; | |
90 | makeModules = lib.lists.flatten (lib.attrsets.mapAttrsToList (n: v: v.modules or []) apacheConfig); | |
91 | makeExtraConfig = (builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList (n: v: v.extraConfig or null) apacheConfig)); | |
36861e95 IB |
92 | moomin = let |
93 | lines = lib.splitString "\n" (lib.fileContents ./moomin.txt); | |
94 | pad = width: str: let | |
95 | padWidth = width - lib.stringLength str; | |
96 | padding = lib.concatStrings (lib.genList (lib.const "0") padWidth); | |
97 | in lib.optionalString (padWidth > 0) padding + str; | |
98 | in | |
99 | lib.imap0 (i: e: ''Header always set "X-Moomin-${pad 2 (builtins.toString i)}" "${e}"'') lines; | |
4288c2f2 | 100 | in |
f8026b6e | 101 | { |
d3452fc5 | 102 | options.myServices.websites.enable = lib.mkEnableOption "enable websites"; |
4288c2f2 | 103 | |
8415083e | 104 | config = lib.mkIf config.myServices.websites.enable { |
d2e703c5 | 105 | services.duplyBackup.profiles.php = { |
6a8252b1 IB |
106 | rootDir = "/var/lib/php"; |
107 | }; | |
4288c2f2 IB |
108 | users.users.wwwrun.extraGroups = [ "keys" ]; |
109 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
110 | ||
4288c2f2 IB |
111 | secrets.keys = [{ |
112 | dest = "apache-ldap"; | |
113 | user = "wwwrun"; | |
114 | group = "wwwrun"; | |
115 | permissions = "0400"; | |
116 | text = '' | |
117 | <Macro LDAPConnect> | |
118 | <IfModule authnz_ldap_module> | |
119 | AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu STARTTLS | |
120 | AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu | |
ab8f306d | 121 | AuthLDAPBindPassword "${config.myEnv.httpd.ldap.password}" |
4288c2f2 IB |
122 | AuthType Basic |
123 | AuthName "Authentification requise (Acces LDAP)" | |
124 | AuthBasicProvider ldap | |
125 | </IfModule> | |
126 | </Macro> | |
127 | ''; | |
128 | }]; | |
129 | ||
130 | system.activationScripts = { | |
131 | httpd = '' | |
3ffa15ba | 132 | install -d -m 0755 /var/lib/acme/acme-challenges |
4288c2f2 IB |
133 | install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions |
134 | ''; | |
135 | }; | |
136 | ||
137 | services.phpfpm = { | |
4288c2f2 IB |
138 | phpOptions = '' |
139 | session.save_path = "/var/lib/php/sessions" | |
140 | post_max_size = 20M | |
141 | ; 15 days (seconds) | |
142 | session.gc_maxlifetime = 1296000 | |
143 | ; 30 days (minutes) | |
144 | session.cache_expire = 43200 | |
145 | ''; | |
5400b9b6 IB |
146 | settings = { |
147 | log_level = "notice"; | |
148 | }; | |
4288c2f2 IB |
149 | }; |
150 | ||
17f6eae9 IB |
151 | services.filesWatcher.httpdProd.paths = [ "/var/secrets/apache-ldap" ]; |
152 | services.filesWatcher.httpdInte.paths = [ "/var/secrets/apache-ldap" ]; | |
153 | services.filesWatcher.httpdTools.paths = [ "/var/secrets/apache-ldap" ]; | |
154 | ||
29f8cb85 | 155 | services.websites.env.production = { |
4288c2f2 IB |
156 | enable = true; |
157 | adminAddr = "httpd@immae.eu"; | |
158 | httpdName = "Prod"; | |
159 | ips = | |
ab8f306d | 160 | let ips = config.myEnv.servers.eldiron.ips.production; |
4288c2f2 IB |
161 | in [ips.ip4] ++ (ips.ip6 or []); |
162 | modules = makeModules; | |
163 | extraConfig = makeExtraConfig; | |
164 | fallbackVhost = { | |
165 | certName = "eldiron"; | |
166 | hosts = ["eldiron.immae.eu" ]; | |
167 | root = www_root; | |
168 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
169 | }; | |
170 | }; | |
171 | ||
29f8cb85 | 172 | services.websites.env.integration = { |
4288c2f2 IB |
173 | enable = true; |
174 | adminAddr = "httpd@immae.eu"; | |
175 | httpdName = "Inte"; | |
176 | ips = | |
ab8f306d | 177 | let ips = config.myEnv.servers.eldiron.ips.integration; |
4288c2f2 IB |
178 | in [ips.ip4] ++ (ips.ip6 or []); |
179 | modules = makeModules; | |
36861e95 | 180 | extraConfig = makeExtraConfig ++ moomin; |
4288c2f2 IB |
181 | fallbackVhost = { |
182 | certName = "eldiron"; | |
183 | hosts = ["eldiron.immae.eu" ]; | |
184 | root = www_root; | |
185 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
186 | }; | |
187 | }; | |
188 | ||
29f8cb85 | 189 | services.websites.env.tools = { |
4288c2f2 IB |
190 | enable = true; |
191 | adminAddr = "httpd@immae.eu"; | |
192 | httpdName = "Tools"; | |
193 | ips = | |
ab8f306d | 194 | let ips = config.myEnv.servers.eldiron.ips.main; |
4288c2f2 IB |
195 | in [ips.ip4] ++ (ips.ip6 or []); |
196 | modules = makeModules; | |
197 | extraConfig = makeExtraConfig ++ | |
198 | [ '' | |
199 | RedirectMatch ^/licen[cs]es?_et_tip(ping)?$ https://www.immae.eu/licences_et_tip.html | |
200 | RedirectMatch ^/licen[cs]es?_and_tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html | |
201 | RedirectMatch ^/licen[cs]es?$ https://www.immae.eu/licenses_and_tipping.html | |
202 | RedirectMatch ^/tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html | |
203 | RedirectMatch ^/(mentions|mentions_legales|legal)$ https://www.immae.eu/mentions.html | |
204 | RedirectMatch ^/CGU$ https://www.immae.eu/CGU | |
205 | '' | |
206 | ]; | |
207 | nosslVhost = { | |
208 | enable = true; | |
209 | host = "nossl.immae.eu"; | |
210 | }; | |
211 | fallbackVhost = { | |
212 | certName = "eldiron"; | |
213 | hosts = ["eldiron.immae.eu" ]; | |
214 | root = www_root; | |
215 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
216 | }; | |
217 | }; | |
218 | ||
d3452fc5 IB |
219 | services.websites.webappDirs = { |
220 | _www = ./_www; | |
221 | _theme = pkgs.webapps.apache-theme.theme; | |
222 | }; | |
4288c2f2 | 223 | myServices.websites = { |
d3452fc5 | 224 | capitaines.landing_pages.enable = true; |
4288c2f2 | 225 | |
d3452fc5 IB |
226 | chloe = { |
227 | integration.enable = true; | |
228 | production.enable = true; | |
229 | }; | |
4288c2f2 | 230 | |
6c7d42fc IB |
231 | cip-ca = { |
232 | sympa.enable = true; | |
233 | }; | |
234 | ||
d3452fc5 IB |
235 | connexionswing = { |
236 | integration.enable = true; | |
237 | production.enable = true; | |
238 | }; | |
f8026b6e | 239 | |
d3452fc5 IB |
240 | denise = { |
241 | evariste.enable = true; | |
242 | denisejerome.enable = true; | |
a295d69f | 243 | oms.enable = true; |
f989f3ed | 244 | aventuriers.enable = true; |
a295d69f | 245 | production.enable = true; |
d3452fc5 | 246 | }; |
f8026b6e | 247 | |
d3452fc5 | 248 | emilia.moodle.enable = true; |
f8026b6e | 249 | |
d3452fc5 IB |
250 | florian = { |
251 | app.enable = true; | |
252 | integration.enable = true; | |
253 | production.enable = true; | |
254 | }; | |
f8026b6e | 255 | |
d3452fc5 IB |
256 | immae = { |
257 | production.enable = true; | |
258 | release.enable = true; | |
259 | temp.enable = true; | |
260 | }; | |
f8026b6e | 261 | |
d3452fc5 IB |
262 | isabelle = { |
263 | aten_integration.enable = true; | |
264 | aten_production.enable = true; | |
265 | iridologie.enable = true; | |
266 | }; | |
f8026b6e | 267 | |
d3452fc5 | 268 | jerome.naturaloutil.enable = true; |
f8026b6e | 269 | |
4288c2f2 | 270 | leila.production.enable = true; |
f8026b6e | 271 | |
d3452fc5 IB |
272 | ludivine = { |
273 | integration.enable = true; | |
274 | production.enable = true; | |
275 | }; | |
f8026b6e | 276 | |
4288c2f2 | 277 | nassime.production.enable = true; |
f8026b6e | 278 | |
8722d693 IB |
279 | nathanael.villon.enable = true; |
280 | ||
d3452fc5 IB |
281 | papa = { |
282 | surveillance.enable = true; | |
283 | maison_bbc.enable = true; | |
284 | }; | |
f8026b6e | 285 | |
d3452fc5 IB |
286 | piedsjaloux = { |
287 | integration.enable = true; | |
288 | production.enable = true; | |
289 | }; | |
f8026b6e | 290 | |
d3452fc5 | 291 | richie.production.enable = true; |
f8026b6e | 292 | |
8a05c7fb IB |
293 | syden.peertube.enable = true; |
294 | ||
d3452fc5 IB |
295 | telio_tortay.production.enable = true; |
296 | ||
4c42e0be | 297 | tools.assets.enable = true; |
4288c2f2 | 298 | tools.cloud.enable = true; |
6338573a | 299 | tools.commento.enable = true; |
4288c2f2 IB |
300 | tools.dav.enable = true; |
301 | tools.db.enable = true; | |
302 | tools.diaspora.enable = true; | |
303 | tools.etherpad-lite.enable = true; | |
304 | tools.git.enable = true; | |
305 | tools.mastodon.enable = true; | |
306 | tools.mediagoblin.enable = true; | |
307 | tools.peertube.enable = true; | |
a97118c4 | 308 | tools.performance.enable = true; |
4288c2f2 | 309 | tools.tools.enable = true; |
afcc5de0 | 310 | tools.email.enable = true; |
de6002a1 IB |
311 | |
312 | games.codenames.enable = true; | |
4288c2f2 IB |
313 | }; |
314 | }; | |
f8026b6e | 315 | } |