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