1 { lib, pkgs, config, mypackages-lib, ... }:
4 theme_root = (mypackages-lib.apache-theme {}).theme;
7 # Only give 5 seconds to workers to finish their work
9 GracefulShutdownTimeout 5
13 # This setting permits to ignore time-based cache for files in the
15 # If a client requires an If-Modified-Since from timestamp 1, then
16 # this header is removed, and if the response contains a
17 # too old Last-Modified tag, then it is removed too
19 <If "%{HTTP:If-Modified-Since} =~ /01 Jan 1970 00:00:01/" >
20 RequestHeader unset If-Modified-Since
22 Header unset Last-Modified "expr=%{LAST_MODIFIED} < 19991231235959"
26 modules = [ "deflate" "filter" ];
28 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
32 modules = [ "macro" ];
36 <Macro Stats %{domain}>
37 Alias /webstats ${config.services.webstats.dataDir}/%{domain}
38 <Directory ${config.services.webstats.dataDir}/%{domain}>
39 DirectoryIndex index.html
45 Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu
51 modules = [ "ldap" "authnz_ldap" ];
53 <IfModule ldap_module>
54 LDAPSharedCacheSize 500000
57 LDAPOpCacheEntries 1024
61 Include ${config.secrets.fullPaths."apache-ldap"}
66 ErrorDocument 500 /maintenance_immae.html
67 ErrorDocument 501 /maintenance_immae.html
68 ErrorDocument 502 /maintenance_immae.html
69 ErrorDocument 503 /maintenance_immae.html
70 ErrorDocument 504 /maintenance_immae.html
71 Alias /maintenance_immae.html ${www_root}/maintenance_immae.html
72 ProxyPass /maintenance_immae.html !
74 AliasMatch "(.*)/googleb6d69446ff4ca3e5.html" ${www_root}/googleb6d69446ff4ca3e5.html
75 <Directory ${www_root}>
82 extraConfig = (mypackages-lib.apache-theme { inherit theme_root; }).apacheConfig;
85 modules = [ "http2" ];
92 LogFormat "%{Host}i:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost
96 makeModules = lib.lists.flatten (lib.attrsets.mapAttrsToList (n: v: v.modules or []) apacheConfig);
97 makeExtraConfig = (builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList (n: v: v.extraConfig or null) apacheConfig));
99 lines = lib.splitString "\n" (lib.fileContents ./moomin.txt);
100 pad = width: str: let
101 padWidth = width - lib.stringLength str;
102 padding = lib.concatStrings (lib.genList (lib.const "0") padWidth);
103 in lib.optionalString (padWidth > 0) padding + str;
105 lib.imap0 (i: e: ''Header always set "X-Moomin-${pad 2 (builtins.toString i)}" "${e}"'') lines;
109 ./immae/production.nix
138 ./games/terraforming-mars
141 options.myServices.websites.enable = lib.mkEnableOption "enable websites";
143 config = lib.mkIf config.myServices.websites.enable {
144 myServices.dns.zones."immae.eu".subdomains = with config.myServices.dns.helpers;
146 games = ips servers.eldiron.ips.main;
147 nossl = ips servers.eldiron.ips.main;
150 myServices.chatonsProperties.hostings.web = {
151 file.datetime = "2022-08-22T01:30:00";
153 name = "Hébergement Web";
154 description = "Service d'hébergement web avec php/mysql/postgresql";
155 website = "https://www.immae.eu";
157 status.description = "OK";
158 registration.load = "OPEN";
159 install.type = "PACKAGE";
162 name = "Apache Httpd";
163 website = "https://httpd.apache.org/";
164 license.url = "https://www.apache.org/licenses/";
165 license.name = "Apache License Version 2";
166 version = pkgs.apacheHttpd.version;
167 source.url = "https://httpd.apache.org/download.cgi";
168 modules = "openssh,pure-ftpd";
171 users.users.wwwrun.extraGroups = [ "keys" ];
172 networking.firewall.allowedTCPPorts = [ 80 443 ];
174 secrets.keys."apache-ldap" = {
177 permissions = "0400";
180 <IfModule authnz_ldap_module>
181 AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu STARTTLS
182 AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu
183 AuthLDAPBindPassword "${config.myEnv.httpd.ldap.password}"
185 AuthName "Authentification requise (Acces LDAP)"
186 AuthBasicProvider ldap
192 system.activationScripts = {
194 install -d -m 0755 /var/lib/acme/acme-challenges
195 install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions
201 session.save_path = "/var/lib/php/sessions"
204 session.gc_maxlifetime = 1296000
206 session.cache_expire = 43200
209 log_level = "notice";
213 services.websites.env.production = {
215 moduleType = "container";
216 adminAddr = "httpd@immae.eu";
217 bindMounts."/var/lib/ftp" = {};
218 # FIXME: Bind directly the needed files
219 bindMounts."/var/secrets" = {};
220 bindMounts."/var/lib/goaccess" = {};
221 bindMounts."/var/lib/acme" = {};
222 bindMounts."/run/phpfpm" = {};
224 let ips = config.myEnv.servers.eldiron.ips.production;
225 in (ips.ip4 or []) ++ (ips.ip6 or []);
226 modules = makeModules;
227 extraConfig = makeExtraConfig;
229 certName = "eldiron";
230 hosts = ["eldiron.immae.eu" ];
232 extraConfig = [ "DirectoryIndex index.htm" ];
236 services.websites.env.integration = {
238 moduleType = "container";
239 adminAddr = "httpd@immae.eu";
240 bindMounts."/var/lib/ftp" = {};
241 bindMounts."/var/secrets" = {};
242 bindMounts."/var/lib/goaccess" = {};
243 bindMounts."/var/lib/acme" = {};
244 bindMounts."/run/phpfpm" = {};
246 let ips = config.myEnv.servers.eldiron.ips.integration;
247 in (ips.ip4 or []) ++ (ips.ip6 or []);
248 modules = makeModules;
249 extraConfig = makeExtraConfig ++ moomin;
251 certName = "integration";
252 hosts = ["eldiron.immae.eu" ];
254 extraConfig = [ "DirectoryIndex index.htm" ];
256 watchPaths = [ config.secrets.fullPaths."apache-ldap" ];
259 services.websites.env.tools = {
262 adminAddr = "httpd@immae.eu";
264 let ips = config.myEnv.servers.eldiron.ips.main;
265 in (ips.ip4 or []) ++ (ips.ip6 or []);
266 modules = makeModules;
267 extraConfig = makeExtraConfig ++
269 RedirectMatch ^/licen[cs]es?_et_tip(ping)?$ https://www.immae.eu/licences_et_tip.html
270 RedirectMatch ^/licen[cs]es?_and_tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html
271 RedirectMatch ^/licen[cs]es?$ https://www.immae.eu/licenses_and_tipping.html
272 RedirectMatch ^/tip(ping)?$ https://www.immae.eu/licenses_and_tipping.html
273 RedirectMatch ^/(mentions|mentions_legales|legal)$ https://www.immae.eu/mentions.html
274 RedirectMatch ^/CGU$ https://www.immae.eu/CGU
279 host = "nossl.immae.eu";
283 certName = "eldiron";
284 hosts = ["eldiron.immae.eu" ];
286 extraConfig = [ "DirectoryIndex index.htm" ];
288 watchPaths = [ config.secrets.fullPaths."apache-ldap" ];
291 myServices.websites = {
293 production.enable = true;
294 release.enable = true;
297 tools.assets.enable = true;
298 tools.cloud.enable = true;
299 tools.commento.enable = true;
300 tools.cryptpad.enable = true;
301 tools.dav.enable = true;
302 tools.db.enable = true;
303 tools.diaspora.enable = true;
304 tools.etherpad-lite.enable = true;
305 tools.git.enable = true;
306 tools.mastodon.enable = true;
307 tools.mediagoblin.enable = true;
308 tools.peertube.enable = true;
309 tools.performance.enable = true;
310 tools.tools.enable = true;
311 tools.email.enable = true;
312 tools.stats.enable = false;
313 tools.visio.enable = true;
315 games.codenames.enable = true;
316 games.terraforming-mars.enable = true;