]>
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 = { | |
6 | gzip = { | |
7 | modules = [ "deflate" "filter" ]; | |
8 | extraConfig = '' | |
9 | AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript | |
10 | ''; | |
11 | }; | |
12 | macros = { | |
13 | modules = [ "macro" ]; | |
14 | }; | |
15 | stats = { | |
16 | extraConfig = '' | |
17 | <Macro Stats %{domain}> | |
18 | Alias /webstats ${config.services.webstats.dataDir}/%{domain} | |
19 | <Directory ${config.services.webstats.dataDir}/%{domain}> | |
20 | DirectoryIndex index.html | |
21 | AllowOverride None | |
22 | Require all granted | |
23 | </Directory> | |
24 | <Location /webstats> | |
25 | Use LDAPConnect | |
26 | Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu | |
27 | </Location> | |
28 | </Macro> | |
29 | ''; | |
30 | }; | |
31 | ldap = { | |
32 | modules = [ "ldap" "authnz_ldap" ]; | |
33 | extraConfig = '' | |
34 | <IfModule ldap_module> | |
35 | LDAPSharedCacheSize 500000 | |
36 | LDAPCacheEntries 1024 | |
37 | LDAPCacheTTL 600 | |
38 | LDAPOpCacheEntries 1024 | |
39 | LDAPOpCacheTTL 600 | |
40 | </IfModule> | |
41 | ||
42 | Include /var/secrets/apache-ldap | |
43 | ''; | |
44 | }; | |
45 | global = { | |
d3452fc5 IB |
46 | extraConfig = '' |
47 | ErrorDocument 500 /maintenance_immae.html | |
48 | ErrorDocument 501 /maintenance_immae.html | |
49 | ErrorDocument 502 /maintenance_immae.html | |
50 | ErrorDocument 503 /maintenance_immae.html | |
51 | ErrorDocument 504 /maintenance_immae.html | |
52 | Alias /maintenance_immae.html ${www_root}/maintenance_immae.html | |
53 | ProxyPass /maintenance_immae.html ! | |
54 | ||
55 | AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${www_root}/googleb6d69446ff4ca3e5.html | |
56 | <Directory ${www_root}> | |
57 | AllowOverride None | |
58 | Require all granted | |
59 | </Directory> | |
60 | ''; | |
4288c2f2 IB |
61 | }; |
62 | apaxy = { | |
63 | extraConfig = (pkgs.webapps.apache-theme.override { inherit theme_root; }).apacheConfig; | |
64 | }; | |
65 | http2 = { | |
66 | modules = [ "http2" ]; | |
67 | extraConfig = '' | |
68 | Protocols h2 http/1.1 | |
69 | ''; | |
70 | }; | |
71 | customLog = { | |
72 | extraConfig = '' | |
494d0718 | 73 | LogFormat "%{Host}i:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost |
4288c2f2 IB |
74 | ''; |
75 | }; | |
76 | }; | |
77 | makeModules = lib.lists.flatten (lib.attrsets.mapAttrsToList (n: v: v.modules or []) apacheConfig); | |
78 | makeExtraConfig = (builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList (n: v: v.extraConfig or null) apacheConfig)); | |
79 | in | |
f8026b6e | 80 | { |
d3452fc5 | 81 | options.myServices.websites.enable = lib.mkEnableOption "enable websites"; |
4288c2f2 | 82 | |
8415083e | 83 | config = lib.mkIf config.myServices.websites.enable { |
d2e703c5 | 84 | services.duplyBackup.profiles.php = { |
6a8252b1 IB |
85 | rootDir = "/var/lib/php"; |
86 | }; | |
4288c2f2 IB |
87 | users.users.wwwrun.extraGroups = [ "keys" ]; |
88 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
89 | ||
90 | nixpkgs.overlays = [ (self: super: rec { | |
91 | #openssl = self.openssl_1_1; | |
92 | php = php72; | |
93 | php72 = (super.php72.override { | |
5400b9b6 | 94 | config.php.mysqlnd = true; |
4288c2f2 | 95 | config.php.mysqli = false; |
5400b9b6 | 96 | config.php.mhash = true; # Is it needed? |
4288c2f2 IB |
97 | }).overrideAttrs(old: rec { |
98 | # Didn't manage to build with mysqli + mysql_config connector | |
99 | configureFlags = old.configureFlags ++ [ | |
100 | "--with-mysqli=shared,mysqlnd" | |
101 | ]; | |
102 | # preConfigure = (old.preConfigure or "") + '' | |
103 | # export CPPFLAGS="$CPPFLAGS -I${pkgs.mariadb}/include/mysql/server"; | |
104 | # sed -i -e 's/#include "mysqli_priv.h"/#include "mysqli_priv.h"\n#include <mysql_version.h>/' \ | |
105 | # ext/mysqli/mysqli.c ext/mysqli/mysqli_prop.c | |
106 | # ''; | |
107 | }); | |
108 | phpPackages = super.php72Packages.override { inherit php; }; | |
109 | }) ]; | |
110 | ||
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 = { | |
138 | phpPackage = pkgs.php; | |
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; | |
181 | extraConfig = makeExtraConfig; | |
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 = { |
d3452fc5 | 225 | capitaines.landing_pages.enable = true; |
4288c2f2 | 226 | |
d3452fc5 IB |
227 | chloe = { |
228 | integration.enable = true; | |
229 | production.enable = true; | |
230 | }; | |
4288c2f2 | 231 | |
d3452fc5 IB |
232 | connexionswing = { |
233 | integration.enable = true; | |
234 | production.enable = true; | |
235 | }; | |
f8026b6e | 236 | |
d3452fc5 IB |
237 | denise = { |
238 | evariste.enable = true; | |
239 | denisejerome.enable = true; | |
240 | }; | |
f8026b6e | 241 | |
d3452fc5 | 242 | emilia.moodle.enable = true; |
f8026b6e | 243 | |
d3452fc5 IB |
244 | florian = { |
245 | app.enable = true; | |
246 | integration.enable = true; | |
247 | production.enable = true; | |
248 | }; | |
f8026b6e | 249 | |
d3452fc5 IB |
250 | immae = { |
251 | production.enable = true; | |
252 | release.enable = true; | |
253 | temp.enable = true; | |
254 | }; | |
f8026b6e | 255 | |
d3452fc5 IB |
256 | isabelle = { |
257 | aten_integration.enable = true; | |
258 | aten_production.enable = true; | |
259 | iridologie.enable = true; | |
260 | }; | |
f8026b6e | 261 | |
d3452fc5 | 262 | jerome.naturaloutil.enable = true; |
f8026b6e | 263 | |
4288c2f2 | 264 | leila.production.enable = true; |
f8026b6e | 265 | |
d3452fc5 IB |
266 | ludivine = { |
267 | integration.enable = true; | |
268 | production.enable = true; | |
269 | }; | |
f8026b6e | 270 | |
4288c2f2 | 271 | nassime.production.enable = true; |
f8026b6e | 272 | |
8722d693 IB |
273 | nathanael.villon.enable = true; |
274 | ||
d3452fc5 IB |
275 | papa = { |
276 | surveillance.enable = true; | |
277 | maison_bbc.enable = true; | |
278 | }; | |
f8026b6e | 279 | |
d3452fc5 IB |
280 | piedsjaloux = { |
281 | integration.enable = true; | |
282 | production.enable = true; | |
283 | }; | |
f8026b6e | 284 | |
d3452fc5 | 285 | richie.production.enable = true; |
f8026b6e | 286 | |
8a05c7fb IB |
287 | syden.peertube.enable = true; |
288 | ||
d3452fc5 IB |
289 | telio_tortay.production.enable = true; |
290 | ||
4288c2f2 IB |
291 | tools.cloud.enable = true; |
292 | tools.dav.enable = true; | |
293 | tools.db.enable = true; | |
294 | tools.diaspora.enable = true; | |
295 | tools.etherpad-lite.enable = true; | |
296 | tools.git.enable = true; | |
297 | tools.mastodon.enable = true; | |
298 | tools.mediagoblin.enable = true; | |
299 | tools.peertube.enable = true; | |
300 | tools.tools.enable = true; | |
afcc5de0 | 301 | tools.email.enable = true; |
de6002a1 IB |
302 | |
303 | games.codenames.enable = true; | |
4288c2f2 IB |
304 | }; |
305 | }; | |
f8026b6e | 306 | } |