]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/default.nix
Ateliers du changement
[perso/Immae/Config/Nix.git] / modules / private / websites / default.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
4288c2f2 2let
750fe5a4 3 www_root = ./_www;
776aa360 4 theme_root = (pkgs.webapps.apache-theme {}).theme;
4288c2f2 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
da30ae4f 55 Include ${config.secrets.fullPaths."apache-ldap"}
4288c2f2
IB
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 = {
776aa360 76 extraConfig = (pkgs.webapps.apache-theme { inherit theme_root; }).apacheConfig;
4288c2f2
IB
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 100in
f8026b6e 101{
d3452fc5 102 options.myServices.websites.enable = lib.mkEnableOption "enable websites";
4288c2f2 103
8415083e 104 config = lib.mkIf config.myServices.websites.enable {
120bcf4d
IB
105 myServices.chatonsProperties.hostings.web = {
106 file.datetime = "2022-08-22T01:30:00";
107 hosting = {
108 name = "Hébergement Web";
109 description = "Service d'hébergement web avec php/mysql/postgresql";
110 website = "https://www.immae.eu";
111 status.level = "OK";
112 status.description = "OK";
113 registration.load = "OPEN";
114 install.type = "PACKAGE";
115 };
116 software = {
117 name = "Apache Httpd";
118 website = "https://httpd.apache.org/";
119 license.url = "https://www.apache.org/licenses/";
120 license.name = "Apache License Version 2";
121 version = pkgs.apacheHttpd.version;
122 source.url = "https://httpd.apache.org/download.cgi";
123 modules = "openssh,pure-ftpd";
124 };
125 };
4288c2f2
IB
126 users.users.wwwrun.extraGroups = [ "keys" ];
127 networking.firewall.allowedTCPPorts = [ 80 443 ];
128
4c4652aa 129 secrets.keys."apache-ldap" = {
4288c2f2
IB
130 user = "wwwrun";
131 group = "wwwrun";
132 permissions = "0400";
133 text = ''
134 <Macro LDAPConnect>
135 <IfModule authnz_ldap_module>
136 AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu STARTTLS
137 AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu
ab8f306d 138 AuthLDAPBindPassword "${config.myEnv.httpd.ldap.password}"
4288c2f2
IB
139 AuthType Basic
140 AuthName "Authentification requise (Acces LDAP)"
141 AuthBasicProvider ldap
142 </IfModule>
143 </Macro>
144 '';
4c4652aa 145 };
4288c2f2
IB
146
147 system.activationScripts = {
148 httpd = ''
3ffa15ba 149 install -d -m 0755 /var/lib/acme/acme-challenges
4288c2f2
IB
150 install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions
151 '';
152 };
153
154 services.phpfpm = {
4288c2f2
IB
155 phpOptions = ''
156 session.save_path = "/var/lib/php/sessions"
157 post_max_size = 20M
158 ; 15 days (seconds)
159 session.gc_maxlifetime = 1296000
160 ; 30 days (minutes)
161 session.cache_expire = 43200
162 '';
5400b9b6
IB
163 settings = {
164 log_level = "notice";
165 };
4288c2f2
IB
166 };
167
da30ae4f
IB
168 services.filesWatcher.httpdProd.paths = [ config.secrets.fullPaths."apache-ldap" ];
169 services.filesWatcher.httpdInte.paths = [ config.secrets.fullPaths."apache-ldap" ];
170 services.filesWatcher.httpdTools.paths = [ config.secrets.fullPaths."apache-ldap" ];
17f6eae9 171
29f8cb85 172 services.websites.env.production = {
4288c2f2
IB
173 enable = true;
174 adminAddr = "httpd@immae.eu";
175 httpdName = "Prod";
176 ips =
ab8f306d 177 let ips = config.myEnv.servers.eldiron.ips.production;
05becbbb 178 in (ips.ip4 or []) ++ (ips.ip6 or []);
4288c2f2
IB
179 modules = makeModules;
180 extraConfig = makeExtraConfig;
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.integration = {
4288c2f2
IB
190 enable = true;
191 adminAddr = "httpd@immae.eu";
192 httpdName = "Inte";
193 ips =
ab8f306d 194 let ips = config.myEnv.servers.eldiron.ips.integration;
05becbbb 195 in (ips.ip4 or []) ++ (ips.ip6 or []);
4288c2f2 196 modules = makeModules;
36861e95 197 extraConfig = makeExtraConfig ++ moomin;
4288c2f2 198 fallbackVhost = {
2ff9258e 199 certName = "integration";
4288c2f2
IB
200 hosts = ["eldiron.immae.eu" ];
201 root = www_root;
202 extraConfig = [ "DirectoryIndex index.htm" ];
203 };
204 };
205
29f8cb85 206 services.websites.env.tools = {
4288c2f2
IB
207 enable = true;
208 adminAddr = "httpd@immae.eu";
209 httpdName = "Tools";
210 ips =
ab8f306d 211 let ips = config.myEnv.servers.eldiron.ips.main;
05becbbb 212 in (ips.ip4 or []) ++ (ips.ip6 or []);
4288c2f2
IB
213 modules = makeModules;
214 extraConfig = makeExtraConfig ++
215 [ ''
216 RedirectMatch ^/licen[cs]es?_et_tip(ping)?$ https://www.immae.eu/licences_et_tip.html
217 RedirectMatch ^/licen[cs]es?_and_tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html
218 RedirectMatch ^/licen[cs]es?$ https://www.immae.eu/licenses_and_tipping.html
219 RedirectMatch ^/tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html
220 RedirectMatch ^/(mentions|mentions_legales|legal)$ https://www.immae.eu/mentions.html
221 RedirectMatch ^/CGU$ https://www.immae.eu/CGU
222 ''
223 ];
224 nosslVhost = {
225 enable = true;
226 host = "nossl.immae.eu";
227 };
228 fallbackVhost = {
229 certName = "eldiron";
230 hosts = ["eldiron.immae.eu" ];
231 root = www_root;
232 extraConfig = [ "DirectoryIndex index.htm" ];
233 };
234 };
235
f69e0c01
IB
236 myServices.tools.kanboard.farm.instances.tonnelle = {};
237 myServices.tools.kanboard.farm.instances.gebull = {};
4288c2f2 238 myServices.websites = {
a58a80b2
IB
239 attilax.dolibarr.enable = true;
240
abd7458c 241 bakeer.cloud.enable = true;
d3452fc5 242 capitaines.landing_pages.enable = true;
4288c2f2 243
d3452fc5 244 chloe = {
2ff9258e 245 new.enable = true;
d3452fc5
IB
246 production.enable = true;
247 };
4288c2f2 248
5a412244
IB
249 christophe_carpentier = {
250 website.enable = true;
251 agorakit.enable = true;
252 agora-project.enable = true;
cc0ec972 253 ateliersduchangement.enable = true;
5a412244
IB
254 };
255
6c7d42fc
IB
256 cip-ca = {
257 sympa.enable = true;
258 };
259
d3452fc5
IB
260 connexionswing = {
261 integration.enable = true;
262 production.enable = true;
263 };
f8026b6e 264
d3452fc5
IB
265 denise = {
266 evariste.enable = true;
267 denisejerome.enable = true;
a295d69f 268 oms.enable = true;
2e573da3 269 bingo.enable = true;
f989f3ed 270 aventuriers.enable = true;
a295d69f 271 production.enable = true;
d3452fc5 272 };
f8026b6e 273
c0c7c8b5
IB
274 emilia = {
275 moodle.enable = false;
8ece2579 276 atelierfringant.enable = false;
c0c7c8b5 277 };
f8026b6e 278
d3452fc5
IB
279 florian = {
280 app.enable = true;
281 integration.enable = true;
282 production.enable = true;
283 };
f8026b6e 284
d3452fc5
IB
285 immae = {
286 production.enable = true;
287 release.enable = true;
288 temp.enable = true;
568bfa04 289 dolibarr.enable = true;
d3452fc5 290 };
f8026b6e 291
d3452fc5
IB
292 isabelle = {
293 aten_integration.enable = true;
294 aten_production.enable = true;
295 iridologie.enable = true;
296 };
f8026b6e 297
d3452fc5 298 jerome.naturaloutil.enable = true;
f8026b6e 299
4288c2f2 300 leila.production.enable = true;
f8026b6e 301
5c9a5ec7
IB
302 librezo = {
303 cloud.enable = true;
304 dolibarr.enable = true;
305 dolibarrDev.enable = true;
306 website.enable = true;
307 };
308
d3452fc5
IB
309 ludivine = {
310 integration.enable = true;
311 production.enable = true;
312 };
f8026b6e 313
4288c2f2 314 nassime.production.enable = true;
f8026b6e 315
965b61c2
IB
316 nicecoop = {
317 gestion-compte.enable = true;
318 gestion-compte-integration.enable = true;
319 odoo.enable = true;
5e2c3306 320 dolibarrDev.enable = true;
27da4e10 321 copanier.enable = true;
965b61c2 322 };
76799447
IB
323
324 noctambules = {
325 cloud.enable = true;
326 };
327
d3452fc5
IB
328 papa = {
329 surveillance.enable = true;
330 maison_bbc.enable = true;
331 };
f8026b6e 332
305922df 333 patrick_fodella = {
8ece2579 334 ecolyeu.enable = false;
305922df
IB
335 altermondia.enable = true;
336 };
982dc1fa 337
d3452fc5
IB
338 piedsjaloux = {
339 integration.enable = true;
340 production.enable = true;
341 };
f8026b6e 342
54d97019
IB
343 ressourcerie_banon.production.enable = true;
344 ressourcerie_banon.cryptpad.enable = true;
345 ressourcerie_banon.cloud.enable = true;
346
d3452fc5 347 richie.production.enable = true;
f8026b6e 348
8a05c7fb
IB
349 syden.peertube.enable = true;
350
d3452fc5
IB
351 telio_tortay.production.enable = true;
352
4c42e0be 353 tools.assets.enable = true;
4288c2f2 354 tools.cloud.enable = true;
6338573a 355 tools.commento.enable = true;
8c91e92c 356 tools.cryptpad.enable = true;
4288c2f2
IB
357 tools.dav.enable = true;
358 tools.db.enable = true;
359 tools.diaspora.enable = true;
360 tools.etherpad-lite.enable = true;
361 tools.git.enable = true;
362 tools.mastodon.enable = true;
363 tools.mediagoblin.enable = true;
364 tools.peertube.enable = true;
a97118c4 365 tools.performance.enable = true;
4288c2f2 366 tools.tools.enable = true;
afcc5de0 367 tools.email.enable = true;
a565d58b 368 tools.stats.enable = false;
bdaca01e 369 tools.visio.enable = true;
de6002a1
IB
370
371 games.codenames.enable = true;
f036e975 372 games.terraforming-mars.enable = true;
4288c2f2
IB
373 };
374 };
f8026b6e 375}