]>
Commit | Line | Data |
---|---|---|
4288c2f2 IB |
1 | { lib, pkgs, config, myconfig, ... }: |
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 = { | |
46 | extraConfig = (pkgs.webapps.apache-default.override { inherit www_root;}).apacheConfig; | |
47 | }; | |
48 | apaxy = { | |
49 | extraConfig = (pkgs.webapps.apache-theme.override { inherit theme_root; }).apacheConfig; | |
50 | }; | |
51 | http2 = { | |
52 | modules = [ "http2" ]; | |
53 | extraConfig = '' | |
54 | Protocols h2 http/1.1 | |
55 | ''; | |
56 | }; | |
57 | customLog = { | |
58 | extraConfig = '' | |
494d0718 | 59 | LogFormat "%{Host}i:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost |
4288c2f2 IB |
60 | ''; |
61 | }; | |
62 | }; | |
63 | makeModules = lib.lists.flatten (lib.attrsets.mapAttrsToList (n: v: v.modules or []) apacheConfig); | |
64 | makeExtraConfig = (builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList (n: v: v.extraConfig or null) apacheConfig)); | |
65 | in | |
f8026b6e | 66 | { |
4288c2f2 IB |
67 | options.myServices.websites.webappDirs = lib.mkOption { |
68 | type = lib.types.attrsOf lib.types.path; | |
69 | description = '' | |
70 | Webapp paths to create in /run/current-system/webapps | |
71 | ''; | |
72 | default = {}; | |
73 | }; | |
74 | ||
75 | config = { | |
6a8252b1 IB |
76 | services.backup.profiles.php = { |
77 | rootDir = "/var/lib/php"; | |
78 | }; | |
4288c2f2 IB |
79 | users.users.wwwrun.extraGroups = [ "keys" ]; |
80 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
81 | ||
82 | nixpkgs.overlays = [ (self: super: rec { | |
83 | #openssl = self.openssl_1_1; | |
84 | php = php72; | |
85 | php72 = (super.php72.override { | |
86 | mysql.connector-c = self.mariadb; | |
87 | config.php.mysqlnd = false; | |
88 | config.php.mysqli = false; | |
89 | }).overrideAttrs(old: rec { | |
90 | # Didn't manage to build with mysqli + mysql_config connector | |
91 | configureFlags = old.configureFlags ++ [ | |
92 | "--with-mysqli=shared,mysqlnd" | |
93 | ]; | |
94 | # preConfigure = (old.preConfigure or "") + '' | |
95 | # export CPPFLAGS="$CPPFLAGS -I${pkgs.mariadb}/include/mysql/server"; | |
96 | # sed -i -e 's/#include "mysqli_priv.h"/#include "mysqli_priv.h"\n#include <mysql_version.h>/' \ | |
97 | # ext/mysqli/mysqli.c ext/mysqli/mysqli_prop.c | |
98 | # ''; | |
99 | }); | |
100 | phpPackages = super.php72Packages.override { inherit php; }; | |
101 | }) ]; | |
102 | ||
103 | secrets.keys = [{ | |
104 | dest = "apache-ldap"; | |
105 | user = "wwwrun"; | |
106 | group = "wwwrun"; | |
107 | permissions = "0400"; | |
108 | text = '' | |
109 | <Macro LDAPConnect> | |
110 | <IfModule authnz_ldap_module> | |
111 | AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu STARTTLS | |
112 | AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu | |
113 | AuthLDAPBindPassword "${myconfig.env.httpd.ldap.password}" | |
114 | AuthType Basic | |
115 | AuthName "Authentification requise (Acces LDAP)" | |
116 | AuthBasicProvider ldap | |
117 | </IfModule> | |
118 | </Macro> | |
119 | ''; | |
120 | }]; | |
121 | ||
122 | system.activationScripts = { | |
123 | httpd = '' | |
124 | install -d -m 0755 ${config.security.acme.directory}/acme-challenge | |
125 | install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions | |
126 | ''; | |
127 | }; | |
128 | ||
129 | services.phpfpm = { | |
130 | phpPackage = pkgs.php; | |
131 | phpOptions = '' | |
132 | session.save_path = "/var/lib/php/sessions" | |
133 | post_max_size = 20M | |
134 | ; 15 days (seconds) | |
135 | session.gc_maxlifetime = 1296000 | |
136 | ; 30 days (minutes) | |
137 | session.cache_expire = 43200 | |
138 | ''; | |
139 | extraConfig = '' | |
140 | log_level = notice | |
141 | ''; | |
142 | }; | |
143 | ||
17f6eae9 IB |
144 | services.filesWatcher.httpdProd.paths = [ "/var/secrets/apache-ldap" ]; |
145 | services.filesWatcher.httpdInte.paths = [ "/var/secrets/apache-ldap" ]; | |
146 | services.filesWatcher.httpdTools.paths = [ "/var/secrets/apache-ldap" ]; | |
147 | ||
29f8cb85 | 148 | services.websites.env.production = { |
4288c2f2 IB |
149 | enable = true; |
150 | adminAddr = "httpd@immae.eu"; | |
151 | httpdName = "Prod"; | |
152 | ips = | |
153 | let ips = myconfig.env.servers.eldiron.ips.production; | |
154 | in [ips.ip4] ++ (ips.ip6 or []); | |
155 | modules = makeModules; | |
156 | extraConfig = makeExtraConfig; | |
157 | fallbackVhost = { | |
158 | certName = "eldiron"; | |
159 | hosts = ["eldiron.immae.eu" ]; | |
160 | root = www_root; | |
161 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
162 | }; | |
163 | }; | |
164 | ||
29f8cb85 | 165 | services.websites.env.integration = { |
4288c2f2 IB |
166 | enable = true; |
167 | adminAddr = "httpd@immae.eu"; | |
168 | httpdName = "Inte"; | |
169 | ips = | |
170 | let ips = myconfig.env.servers.eldiron.ips.integration; | |
171 | in [ips.ip4] ++ (ips.ip6 or []); | |
172 | modules = makeModules; | |
173 | extraConfig = makeExtraConfig; | |
174 | fallbackVhost = { | |
175 | certName = "eldiron"; | |
176 | hosts = ["eldiron.immae.eu" ]; | |
177 | root = www_root; | |
178 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
179 | }; | |
180 | }; | |
181 | ||
29f8cb85 | 182 | services.websites.env.tools = { |
4288c2f2 IB |
183 | enable = true; |
184 | adminAddr = "httpd@immae.eu"; | |
185 | httpdName = "Tools"; | |
186 | ips = | |
187 | let ips = myconfig.env.servers.eldiron.ips.main; | |
188 | in [ips.ip4] ++ (ips.ip6 or []); | |
189 | modules = makeModules; | |
190 | extraConfig = makeExtraConfig ++ | |
191 | [ '' | |
192 | RedirectMatch ^/licen[cs]es?_et_tip(ping)?$ https://www.immae.eu/licences_et_tip.html | |
193 | RedirectMatch ^/licen[cs]es?_and_tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html | |
194 | RedirectMatch ^/licen[cs]es?$ https://www.immae.eu/licenses_and_tipping.html | |
195 | RedirectMatch ^/tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html | |
196 | RedirectMatch ^/(mentions|mentions_legales|legal)$ https://www.immae.eu/mentions.html | |
197 | RedirectMatch ^/CGU$ https://www.immae.eu/CGU | |
198 | '' | |
199 | ]; | |
200 | nosslVhost = { | |
201 | enable = true; | |
202 | host = "nossl.immae.eu"; | |
203 | }; | |
204 | fallbackVhost = { | |
205 | certName = "eldiron"; | |
206 | hosts = ["eldiron.immae.eu" ]; | |
207 | root = www_root; | |
208 | extraConfig = [ "DirectoryIndex index.htm" ]; | |
209 | }; | |
210 | }; | |
211 | ||
212 | system.extraSystemBuilderCmds = lib.mkIf (builtins.length (builtins.attrValues config.myServices.websites.webappDirs) > 0) '' | |
213 | mkdir -p $out/webapps | |
214 | ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (name: path: "ln -s ${path} $out/webapps/${name}") config.myServices.websites.webappDirs)} | |
215 | ''; | |
216 | ||
217 | myServices.websites = { | |
218 | webappDirs = { | |
219 | _www = pkgs.webapps.apache-default.www; | |
220 | _theme = pkgs.webapps.apache-theme.theme; | |
221 | }; | |
222 | ||
223 | aten.integration.enable = true; | |
224 | aten.production.enable = true; | |
225 | ||
226 | capitaines.production.enable = true; | |
f8026b6e | 227 | |
4288c2f2 IB |
228 | chloe.integration.enable = true; |
229 | chloe.production.enable = true; | |
f8026b6e | 230 | |
4288c2f2 IB |
231 | connexionswing.integration.enable = true; |
232 | connexionswing.production.enable = true; | |
f8026b6e | 233 | |
4288c2f2 | 234 | denisejerome.production.enable = true; |
f8026b6e | 235 | |
4288c2f2 | 236 | emilia.production.enable = true; |
f8026b6e | 237 | |
4288c2f2 IB |
238 | florian.app.enable = true; |
239 | florian.integration.enable = true; | |
240 | florian.production.enable = true; | |
f8026b6e | 241 | |
4288c2f2 IB |
242 | immae.production.enable = true; |
243 | immae.release.enable = true; | |
244 | immae.temp.enable = true; | |
f8026b6e | 245 | |
4288c2f2 | 246 | leila.production.enable = true; |
f8026b6e | 247 | |
4288c2f2 IB |
248 | ludivinecassal.integration.enable = true; |
249 | ludivinecassal.production.enable = true; | |
f8026b6e | 250 | |
4288c2f2 | 251 | nassime.production.enable = true; |
f8026b6e | 252 | |
4288c2f2 | 253 | naturaloutil.production.enable = true; |
93531b30 | 254 | telioTortay.production.enable = true; |
f8026b6e | 255 | |
4288c2f2 | 256 | papa.surveillance.enable = true; |
f8026b6e | 257 | |
4288c2f2 IB |
258 | piedsjaloux.integration.enable = true; |
259 | piedsjaloux.production.enable = true; | |
f8026b6e | 260 | |
4288c2f2 IB |
261 | tools.cloud.enable = true; |
262 | tools.dav.enable = true; | |
263 | tools.db.enable = true; | |
264 | tools.diaspora.enable = true; | |
265 | tools.etherpad-lite.enable = true; | |
266 | tools.git.enable = true; | |
267 | tools.mastodon.enable = true; | |
268 | tools.mediagoblin.enable = true; | |
269 | tools.peertube.enable = true; | |
270 | tools.tools.enable = true; | |
afcc5de0 | 271 | tools.email.enable = true; |
4288c2f2 IB |
272 | }; |
273 | }; | |
f8026b6e | 274 | } |