]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
4288c2f2 | 2 | let |
750fe5a4 IB |
3 | www_root = ./_www; |
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 = { | |
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 { |
4288c2f2 IB |
105 | users.users.wwwrun.extraGroups = [ "keys" ]; |
106 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
107 | ||
4c4652aa | 108 | secrets.keys."apache-ldap" = { |
4288c2f2 IB |
109 | user = "wwwrun"; |
110 | group = "wwwrun"; | |
111 | permissions = "0400"; | |
112 | text = '' | |
113 | <Macro LDAPConnect> | |
114 | <IfModule authnz_ldap_module> | |
115 | AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu STARTTLS | |
116 | AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu | |
ab8f306d | 117 | AuthLDAPBindPassword "${config.myEnv.httpd.ldap.password}" |
4288c2f2 IB |
118 | AuthType Basic |
119 | AuthName "Authentification requise (Acces LDAP)" | |
120 | AuthBasicProvider ldap | |
121 | </IfModule> | |
122 | </Macro> | |
123 | ''; | |
4c4652aa | 124 | }; |
4288c2f2 IB |
125 | |
126 | system.activationScripts = { | |
127 | httpd = '' | |
3ffa15ba | 128 | install -d -m 0755 /var/lib/acme/acme-challenges |
4288c2f2 IB |
129 | install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions |
130 | ''; | |
131 | }; | |
132 | ||
133 | services.phpfpm = { | |
4288c2f2 IB |
134 | phpOptions = '' |
135 | session.save_path = "/var/lib/php/sessions" | |
136 | post_max_size = 20M | |
137 | ; 15 days (seconds) | |
138 | session.gc_maxlifetime = 1296000 | |
139 | ; 30 days (minutes) | |
140 | session.cache_expire = 43200 | |
141 | ''; | |
5400b9b6 IB |
142 | settings = { |
143 | log_level = "notice"; | |
144 | }; | |
4288c2f2 IB |
145 | }; |
146 | ||
da30ae4f IB |
147 | services.filesWatcher.httpdProd.paths = [ config.secrets.fullPaths."apache-ldap" ]; |
148 | services.filesWatcher.httpdInte.paths = [ config.secrets.fullPaths."apache-ldap" ]; | |
149 | services.filesWatcher.httpdTools.paths = [ config.secrets.fullPaths."apache-ldap" ]; | |
17f6eae9 | 150 | |
29f8cb85 | 151 | services.websites.env.production = { |
4288c2f2 IB |
152 | enable = true; |
153 | adminAddr = "httpd@immae.eu"; | |
154 | httpdName = "Prod"; | |
155 | ips = | |
ab8f306d | 156 | let ips = config.myEnv.servers.eldiron.ips.production; |
05becbbb | 157 | in (ips.ip4 or []) ++ (ips.ip6 or []); |
4288c2f2 IB |
158 | modules = makeModules; |
159 | extraConfig = makeExtraConfig; | |
160 | fallbackVhost = { | |
161 | certName = "eldiron"; | |
162 | hosts = ["eldiron.immae.eu" ]; | |
163 | root = www_root; | |
164 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
165 | }; | |
166 | }; | |
167 | ||
29f8cb85 | 168 | services.websites.env.integration = { |
4288c2f2 IB |
169 | enable = true; |
170 | adminAddr = "httpd@immae.eu"; | |
171 | httpdName = "Inte"; | |
172 | ips = | |
ab8f306d | 173 | let ips = config.myEnv.servers.eldiron.ips.integration; |
05becbbb | 174 | in (ips.ip4 or []) ++ (ips.ip6 or []); |
4288c2f2 | 175 | modules = makeModules; |
36861e95 | 176 | extraConfig = makeExtraConfig ++ moomin; |
4288c2f2 | 177 | fallbackVhost = { |
2ff9258e | 178 | certName = "integration"; |
4288c2f2 IB |
179 | hosts = ["eldiron.immae.eu" ]; |
180 | root = www_root; | |
181 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
182 | }; | |
183 | }; | |
184 | ||
29f8cb85 | 185 | services.websites.env.tools = { |
4288c2f2 IB |
186 | enable = true; |
187 | adminAddr = "httpd@immae.eu"; | |
188 | httpdName = "Tools"; | |
189 | ips = | |
ab8f306d | 190 | let ips = config.myEnv.servers.eldiron.ips.main; |
05becbbb | 191 | in (ips.ip4 or []) ++ (ips.ip6 or []); |
4288c2f2 IB |
192 | modules = makeModules; |
193 | extraConfig = makeExtraConfig ++ | |
194 | [ '' | |
195 | RedirectMatch ^/licen[cs]es?_et_tip(ping)?$ https://www.immae.eu/licences_et_tip.html | |
196 | RedirectMatch ^/licen[cs]es?_and_tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html | |
197 | RedirectMatch ^/licen[cs]es?$ https://www.immae.eu/licenses_and_tipping.html | |
198 | RedirectMatch ^/tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html | |
199 | RedirectMatch ^/(mentions|mentions_legales|legal)$ https://www.immae.eu/mentions.html | |
200 | RedirectMatch ^/CGU$ https://www.immae.eu/CGU | |
201 | '' | |
202 | ]; | |
203 | nosslVhost = { | |
204 | enable = true; | |
205 | host = "nossl.immae.eu"; | |
206 | }; | |
207 | fallbackVhost = { | |
208 | certName = "eldiron"; | |
209 | hosts = ["eldiron.immae.eu" ]; | |
210 | root = www_root; | |
211 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
212 | }; | |
213 | }; | |
214 | ||
4288c2f2 | 215 | myServices.websites = { |
abd7458c | 216 | bakeer.cloud.enable = true; |
d3452fc5 | 217 | capitaines.landing_pages.enable = true; |
4288c2f2 | 218 | |
d3452fc5 | 219 | chloe = { |
2ff9258e | 220 | new.enable = true; |
d3452fc5 IB |
221 | production.enable = true; |
222 | }; | |
4288c2f2 | 223 | |
5a412244 IB |
224 | christophe_carpentier = { |
225 | website.enable = true; | |
226 | agorakit.enable = true; | |
227 | agora-project.enable = true; | |
228 | }; | |
229 | ||
6c7d42fc IB |
230 | cip-ca = { |
231 | sympa.enable = true; | |
232 | }; | |
233 | ||
d3452fc5 IB |
234 | connexionswing = { |
235 | integration.enable = true; | |
236 | production.enable = true; | |
237 | }; | |
f8026b6e | 238 | |
d3452fc5 IB |
239 | denise = { |
240 | evariste.enable = true; | |
241 | denisejerome.enable = true; | |
a295d69f | 242 | oms.enable = true; |
2e573da3 | 243 | bingo.enable = true; |
f989f3ed | 244 | aventuriers.enable = true; |
a295d69f | 245 | production.enable = true; |
d3452fc5 | 246 | }; |
f8026b6e | 247 | |
c0c7c8b5 IB |
248 | emilia = { |
249 | moodle.enable = false; | |
250 | atelierfringant.enable = true; | |
251 | }; | |
f8026b6e | 252 | |
d3452fc5 IB |
253 | florian = { |
254 | app.enable = true; | |
255 | integration.enable = true; | |
256 | production.enable = true; | |
257 | }; | |
f8026b6e | 258 | |
d3452fc5 IB |
259 | immae = { |
260 | production.enable = true; | |
261 | release.enable = true; | |
262 | temp.enable = true; | |
263 | }; | |
f8026b6e | 264 | |
d3452fc5 IB |
265 | isabelle = { |
266 | aten_integration.enable = true; | |
267 | aten_production.enable = true; | |
268 | iridologie.enable = true; | |
269 | }; | |
f8026b6e | 270 | |
d3452fc5 | 271 | jerome.naturaloutil.enable = true; |
f8026b6e | 272 | |
4288c2f2 | 273 | leila.production.enable = true; |
f8026b6e | 274 | |
5c9a5ec7 IB |
275 | librezo = { |
276 | cloud.enable = true; | |
277 | dolibarr.enable = true; | |
278 | dolibarrDev.enable = true; | |
279 | website.enable = true; | |
280 | }; | |
281 | ||
d3452fc5 IB |
282 | ludivine = { |
283 | integration.enable = true; | |
284 | production.enable = true; | |
285 | }; | |
f8026b6e | 286 | |
4288c2f2 | 287 | nassime.production.enable = true; |
f8026b6e | 288 | |
87949cb9 | 289 | nath.villon.enable = true; |
8722d693 | 290 | |
965b61c2 IB |
291 | nicecoop = { |
292 | gestion-compte.enable = true; | |
293 | gestion-compte-integration.enable = true; | |
294 | odoo.enable = true; | |
27da4e10 | 295 | copanier.enable = true; |
965b61c2 | 296 | }; |
d3452fc5 IB |
297 | papa = { |
298 | surveillance.enable = true; | |
299 | maison_bbc.enable = true; | |
300 | }; | |
f8026b6e | 301 | |
305922df IB |
302 | patrick_fodella = { |
303 | ecolyeu.enable = true; | |
304 | altermondia.enable = true; | |
305 | }; | |
982dc1fa | 306 | |
d3452fc5 IB |
307 | piedsjaloux = { |
308 | integration.enable = true; | |
309 | production.enable = true; | |
310 | }; | |
f8026b6e | 311 | |
54d97019 IB |
312 | ressourcerie_banon.production.enable = true; |
313 | ressourcerie_banon.cryptpad.enable = true; | |
314 | ressourcerie_banon.cloud.enable = true; | |
315 | ||
d3452fc5 | 316 | richie.production.enable = true; |
f8026b6e | 317 | |
8a05c7fb IB |
318 | syden.peertube.enable = true; |
319 | ||
d3452fc5 IB |
320 | telio_tortay.production.enable = true; |
321 | ||
4c42e0be | 322 | tools.assets.enable = true; |
4288c2f2 | 323 | tools.cloud.enable = true; |
6338573a | 324 | tools.commento.enable = true; |
8c91e92c | 325 | tools.cryptpad.enable = true; |
4288c2f2 IB |
326 | tools.dav.enable = true; |
327 | tools.db.enable = true; | |
328 | tools.diaspora.enable = true; | |
329 | tools.etherpad-lite.enable = true; | |
330 | tools.git.enable = true; | |
331 | tools.mastodon.enable = true; | |
332 | tools.mediagoblin.enable = true; | |
333 | tools.peertube.enable = true; | |
a97118c4 | 334 | tools.performance.enable = true; |
4288c2f2 | 335 | tools.tools.enable = true; |
afcc5de0 | 336 | tools.email.enable = true; |
a565d58b | 337 | tools.stats.enable = false; |
bdaca01e | 338 | tools.visio.enable = true; |
de6002a1 IB |
339 | |
340 | games.codenames.enable = true; | |
f036e975 | 341 | games.terraforming-mars.enable = true; |
4288c2f2 IB |
342 | }; |
343 | }; | |
f8026b6e | 344 | } |