1 { lib, pkgs, config, myconfig, ... }:
3 www_root = "/run/current-system/webapps/_www";
4 theme_root = "/run/current-system/webapps/_theme";
7 modules = [ "deflate" "filter" ];
9 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
13 modules = [ "macro" ];
17 <Macro Stats %{domain}>
18 Alias /webstats ${config.services.webstats.dataDir}/%{domain}
19 <Directory ${config.services.webstats.dataDir}/%{domain}>
20 DirectoryIndex index.html
26 Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu
32 modules = [ "ldap" "authnz_ldap" ];
34 <IfModule ldap_module>
35 LDAPSharedCacheSize 500000
38 LDAPOpCacheEntries 1024
42 Include /var/secrets/apache-ldap
46 extraConfig = (pkgs.webapps.apache-default.override { inherit www_root;}).apacheConfig;
49 extraConfig = (pkgs.webapps.apache-theme.override { inherit theme_root; }).apacheConfig;
52 modules = [ "http2" ];
59 LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost
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));
67 options.myServices.websites.webappDirs = lib.mkOption {
68 type = lib.types.attrsOf lib.types.path;
70 Webapp paths to create in /run/current-system/webapps
76 users.users.wwwrun.extraGroups = [ "keys" ];
77 networking.firewall.allowedTCPPorts = [ 80 443 ];
79 nixpkgs.overlays = [ (self: super: rec {
80 #openssl = self.openssl_1_1;
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"
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
97 phpPackages = super.php72Packages.override { inherit php; };
101 dest = "apache-ldap";
104 permissions = "0400";
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}"
112 AuthName "Authentification requise (Acces LDAP)"
113 AuthBasicProvider ldap
119 system.activationScripts = {
121 install -d -m 0755 ${config.security.acme.directory}/acme-challenge
122 install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions
127 phpPackage = pkgs.php;
129 session.save_path = "/var/lib/php/sessions"
132 session.gc_maxlifetime = 1296000
134 session.cache_expire = 43200
141 services.websites.production = {
143 adminAddr = "httpd@immae.eu";
146 let ips = myconfig.env.servers.eldiron.ips.production;
147 in [ips.ip4] ++ (ips.ip6 or []);
148 modules = makeModules;
149 extraConfig = makeExtraConfig;
151 certName = "eldiron";
152 hosts = ["eldiron.immae.eu" ];
154 extraConfig = [ "DirectoryIndex index.htm" ];
158 services.websites.integration = {
160 adminAddr = "httpd@immae.eu";
163 let ips = myconfig.env.servers.eldiron.ips.integration;
164 in [ips.ip4] ++ (ips.ip6 or []);
165 modules = makeModules;
166 extraConfig = makeExtraConfig;
168 certName = "eldiron";
169 hosts = ["eldiron.immae.eu" ];
171 extraConfig = [ "DirectoryIndex index.htm" ];
175 services.websites.tools = {
177 adminAddr = "httpd@immae.eu";
180 let ips = myconfig.env.servers.eldiron.ips.main;
181 in [ips.ip4] ++ (ips.ip6 or []);
182 modules = makeModules;
183 extraConfig = makeExtraConfig ++
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
195 host = "nossl.immae.eu";
198 certName = "eldiron";
199 hosts = ["eldiron.immae.eu" ];
201 extraConfig = [ "DirectoryIndex index.htm" ];
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)}
210 myServices.websites = {
212 _www = pkgs.webapps.apache-default.www;
213 _theme = pkgs.webapps.apache-theme.theme;
216 aten.integration.enable = true;
217 aten.production.enable = true;
219 capitaines.production.enable = true;
221 chloe.integration.enable = true;
222 chloe.production.enable = true;
224 connexionswing.integration.enable = true;
225 connexionswing.production.enable = true;
227 denisejerome.production.enable = true;
229 emilia.production.enable = true;
231 florian.app.enable = true;
232 florian.integration.enable = true;
233 florian.production.enable = true;
235 immae.production.enable = true;
236 immae.release.enable = true;
237 immae.temp.enable = true;
239 leila.production.enable = true;
241 ludivinecassal.integration.enable = true;
242 ludivinecassal.production.enable = true;
244 nassime.production.enable = true;
246 naturaloutil.production.enable = true;
248 papa.surveillance.enable = true;
250 piedsjaloux.integration.enable = true;
251 piedsjaloux.production.enable = true;
253 tools.cloud.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;