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