aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/default.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-22 20:01:33 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-22 20:01:33 +0200
commit4288c2f2431fb782b0d512b1b3749187f2374b6a (patch)
treeaaf812414f91d6b695a7507265e7572de8dc477c /modules/private/websites/default.nix
parentf40f5b235b890f46770a22f005f8a0f664cf0562 (diff)
downloadNix-4288c2f2431fb782b0d512b1b3749187f2374b6a.tar.gz
Nix-4288c2f2431fb782b0d512b1b3749187f2374b6a.tar.zst
Nix-4288c2f2431fb782b0d512b1b3749187f2374b6a.zip
Move websites/tools to modules
Diffstat (limited to 'modules/private/websites/default.nix')
-rw-r--r--modules/private/websites/default.nix274
1 files changed, 250 insertions, 24 deletions
diff --git a/modules/private/websites/default.nix b/modules/private/websites/default.nix
index 80d902e..8b02977 100644
--- a/modules/private/websites/default.nix
+++ b/modules/private/websites/default.nix
@@ -1,39 +1,265 @@
1{ ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let
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));
65in
2{ 66{
3 config.myServices.websites.aten.integration.enable = true; 67 options.myServices.websites.webappDirs = lib.mkOption {
4 config.myServices.websites.aten.production.enable = true; 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
141 services.websites.production = {
142 enable = true;
143 adminAddr = "httpd@immae.eu";
144 httpdName = "Prod";
145 ips =
146 let ips = myconfig.env.servers.eldiron.ips.production;
147 in [ips.ip4] ++ (ips.ip6 or []);
148 modules = makeModules;
149 extraConfig = makeExtraConfig;
150 fallbackVhost = {
151 certName = "eldiron";
152 hosts = ["eldiron.immae.eu" ];
153 root = www_root;
154 extraConfig = [ "DirectoryIndex index.htm" ];
155 };
156 };
157
158 services.websites.integration = {
159 enable = true;
160 adminAddr = "httpd@immae.eu";
161 httpdName = "Inte";
162 ips =
163 let ips = myconfig.env.servers.eldiron.ips.integration;
164 in [ips.ip4] ++ (ips.ip6 or []);
165 modules = makeModules;
166 extraConfig = makeExtraConfig;
167 fallbackVhost = {
168 certName = "eldiron";
169 hosts = ["eldiron.immae.eu" ];
170 root = www_root;
171 extraConfig = [ "DirectoryIndex index.htm" ];
172 };
173 };
174
175 services.websites.tools = {
176 enable = true;
177 adminAddr = "httpd@immae.eu";
178 httpdName = "Tools";
179 ips =
180 let ips = myconfig.env.servers.eldiron.ips.main;
181 in [ips.ip4] ++ (ips.ip6 or []);
182 modules = makeModules;
183 extraConfig = makeExtraConfig ++
184 [ ''
185 RedirectMatch ^/licen[cs]es?_et_tip(ping)?$ https://www.immae.eu/licences_et_tip.html
186 RedirectMatch ^/licen[cs]es?_and_tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html
187 RedirectMatch ^/licen[cs]es?$ https://www.immae.eu/licenses_and_tipping.html
188 RedirectMatch ^/tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html
189 RedirectMatch ^/(mentions|mentions_legales|legal)$ https://www.immae.eu/mentions.html
190 RedirectMatch ^/CGU$ https://www.immae.eu/CGU
191 ''
192 ];
193 nosslVhost = {
194 enable = true;
195 host = "nossl.immae.eu";
196 };
197 fallbackVhost = {
198 certName = "eldiron";
199 hosts = ["eldiron.immae.eu" ];
200 root = www_root;
201 extraConfig = [ "DirectoryIndex index.htm" ];
202 };
203 };
204
205 system.extraSystemBuilderCmds = lib.mkIf (builtins.length (builtins.attrValues config.myServices.websites.webappDirs) > 0) ''
206 mkdir -p $out/webapps
207 ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (name: path: "ln -s ${path} $out/webapps/${name}") config.myServices.websites.webappDirs)}
208 '';
209
210 myServices.websites = {
211 webappDirs = {
212 _www = pkgs.webapps.apache-default.www;
213 _theme = pkgs.webapps.apache-theme.theme;
214 };
215
216 aten.integration.enable = true;
217 aten.production.enable = true;
218
219 capitaines.production.enable = true;
5 220
6 config.myServices.websites.capitaines.production.enable = true; 221 chloe.integration.enable = true;
222 chloe.production.enable = true;
7 223
8 config.myServices.websites.chloe.integration.enable = true; 224 connexionswing.integration.enable = true;
9 config.myServices.websites.chloe.production.enable = true; 225 connexionswing.production.enable = true;
10 226
11 config.myServices.websites.connexionswing.integration.enable = true; 227 denisejerome.production.enable = true;
12 config.myServices.websites.connexionswing.production.enable = true;
13 228
14 config.myServices.websites.denisejerome.production.enable = true; 229 emilia.production.enable = true;
15 230
16 config.myServices.websites.emilia.production.enable = true; 231 florian.app.enable = true;
232 florian.integration.enable = true;
233 florian.production.enable = true;
17 234
18 config.myServices.websites.florian.app.enable = true; 235 immae.production.enable = true;
19 config.myServices.websites.florian.integration.enable = true; 236 immae.release.enable = true;
20 config.myServices.websites.florian.production.enable = true; 237 immae.temp.enable = true;
21 238
22 config.myServices.websites.immae.production.enable = true; 239 leila.production.enable = true;
23 config.myServices.websites.immae.release.enable = true;
24 config.myServices.websites.immae.temp.enable = true;
25 240
26 config.myServices.websites.leila.production.enable = true; 241 ludivinecassal.integration.enable = true;
242 ludivinecassal.production.enable = true;
27 243
28 config.myServices.websites.ludivinecassal.integration.enable = true; 244 nassime.production.enable = true;
29 config.myServices.websites.ludivinecassal.production.enable = true;
30 245
31 config.myServices.websites.nassime.production.enable = true; 246 naturaloutil.production.enable = true;
32 247
33 config.myServices.websites.naturaloutil.production.enable = true; 248 papa.surveillance.enable = true;
34 249
35 config.myServices.websites.papa.surveillance.enable = true; 250 piedsjaloux.integration.enable = true;
251 piedsjaloux.production.enable = true;
36 252
37 config.myServices.websites.piedsjaloux.integration.enable = true; 253 tools.cloud.enable = true;
38 config.myServices.websites.piedsjaloux.production.enable = true; 254 tools.dav.enable = true;
255 tools.db.enable = true;
256 tools.diaspora.enable = true;
257 tools.etherpad-lite.enable = true;
258 tools.git.enable = true;
259 tools.mastodon.enable = true;
260 tools.mediagoblin.enable = true;
261 tools.peertube.enable = true;
262 tools.tools.enable = true;
263 };
264 };
39} 265}