+ apacheConfig = {
+ gzip = {
+ modules = [ "deflate" "filter" ];
+ extraConfig = ''
+ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
+ '';
+ };
+ ldap = {
+ modules = [ "ldap" "authnz_ldap" ];
+ extraConfig = assert checkEnv "NIXOPS_HTTP_LDAP_PASSWORD"; ''
+ <IfModule ldap_module>
+ LDAPSharedCacheSize 500000
+ LDAPCacheEntries 1024
+ LDAPCacheTTL 600
+ LDAPOpCacheEntries 1024
+ LDAPOpCacheTTL 600
+ </IfModule>
+
+ <Macro LDAPConnect>
+ <IfModule authnz_ldap_module>
+ AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu
+ AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu
+ AuthLDAPBindPassword "${builtins.getEnv "NIXOPS_HTTP_LDAP_PASSWORD"}"
+ AuthType Basic
+ AuthName "Authentification requise (Acces LDAP)"
+ AuthBasicProvider ldap
+ </IfModule>
+ </Macro>
+
+ <Macro Stats %{domain}>
+ Alias /awstats /var/lib/goaccess/%{domain}
+ <Directory /var/lib/goaccess/%{domain}>
+ DirectoryIndex index.html
+ AllowOverride None
+ Require all granted
+ </Directory>
+ <Location /awstats>
+ Use LDAPConnect
+ Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu
+ </Location>
+ </Macro>
+ '';
+ };
+ http2 = {
+ modules = [ "http2" ];
+ extraConfig = ''
+ Protocols h2 http/1.1
+ '';
+ };
+ customLog = {
+ modules = [];
+ extraConfig = ''
+ LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost
+ '';
+ };
+ };
+ in rec {
+ enable = true;
+ logPerVirtualHost = true;
+ multiProcessingModule = "worker";
+ adminAddr = "httpd@immae.eu";
+ logFormat = "combinedVhost";
+ extraModules = pkgs.lib.lists.unique (
+ mypkgs.adminer.apache.modules ++
+ mypkgs.nextcloud.apache.modules ++
+ mypkgs.connexionswing_dev.apache.modules ++
+ mypkgs.connexionswing_prod.apache.modules ++
+ mypkgs.ludivinecassal_dev.apache.modules ++
+ mypkgs.ludivinecassal_prod.apache.modules ++
+ mypkgs.aten_dev.apache.modules ++
+ mypkgs.aten_prod.apache.modules ++
+ mypkgs.ympd.apache.modules ++
+ mypkgs.git.web.apache.modules ++
+ mypkgs.mantisbt.apache.modules ++
+ pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (n: v: v.modules) apacheConfig) ++
+ [ "macro" ]);
+ extraConfig = builtins.concatStringsSep "\n"
+ (pkgs.lib.attrsets.mapAttrsToList (n: v: v.extraConfig) apacheConfig);
+ virtualHosts = [
+ (withConf "eldiron" // {
+ hostName = "eldiron.immae.eu";
+ documentRoot = ./www;
+ extraConfig = ''
+ DirectoryIndex index.htm
+ '';
+ })
+ (withConf "eldiron" // {
+ hostName = "db-1.immae.eu";
+ documentRoot = null;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.adminer.apache.vhostConf
+ ];
+ })
+ (withConf "eldiron" // {
+ hostName = "tools.immae.eu";
+ documentRoot = null;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.adminer.apache.vhostConf
+ mypkgs.ympd.apache.vhostConf
+ ];
+ })
+ (withConf "eldiron" // {
+ hostName = "connexionswing.immae.eu";
+ serverAliases = [ "sandetludo.immae.eu" ];
+ documentRoot = mypkgs.connexionswing_dev.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.connexionswing_dev.apache.vhostConf
+ ];
+ })
+ (withConf "eldiron" // {
+ hostName = "ludivine.immae.eu";
+ documentRoot = mypkgs.ludivinecassal_dev.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.ludivinecassal_dev.apache.vhostConf
+ ];
+ })
+ (withConf "ludivinecassal" // {
+ hostName = "ludivinecassal.com";
+ serverAliases = [ "www.ludivinecassal.com" ];
+ documentRoot = mypkgs.ludivinecassal_prod.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.ludivinecassal_prod.apache.vhostConf
+ ];
+ })
+ (withConf "eldiron" // {
+ hostName = "dev.aten.pro";
+ documentRoot = mypkgs.aten_dev.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.aten_dev.apache.vhostConf
+ ];
+ })
+ (withConf "aten" // {
+ hostName = "aten.pro";
+ serverAliases = [ "www.aten.pro" ];
+ documentRoot = mypkgs.aten_prod.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.aten_prod.apache.vhostConf
+ ];
+ })
+ (withConf "eldiron" // {
+ hostName = "cloud.immae.eu";
+ documentRoot = mypkgs.nextcloud.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.nextcloud.apache.vhostConf
+ ];
+ })
+ (withConf "eldiron" // {
+ hostName = "git.immae.eu";
+ documentRoot = mypkgs.git.web.webRoot;
+ extraConfig = builtins.concatStringsSep "\n" [
+ mypkgs.git.web.apache.vhostConf
+ mypkgs.mantisbt.apache.vhostConf
+ ] + ''
+ RewriteEngine on
+ RewriteCond %{REQUEST_URI} ^/releases
+ RewriteRule /releases(.*) https://release.immae.eu$1 [P,L]
+ '';
+ })
+ { # Should go last, default fallback
+ listen = [ { ip = "*"; port = 80; } ];
+ hostName = "redirectSSL";
+ serverAliases = [ "*" ];
+ enableSSL = false;
+ logFormat = "combinedVhost";
+ documentRoot = "/var/lib/acme/acme-challenge";
+ extraConfig = ''
+ RewriteEngine on
+ RewriteCond "%{REQUEST_URI}" "!^/\.well-known"
+ RewriteRule ^(.+) https://%{HTTP_HOST}$1 [R=301]
+ # To redirect in specific "VirtualHost *:80", do
+ # RedirectMatch 301 ^/((?!\.well-known.*$).*)$ https://host/$1
+ # rather than rewrite
+ '';
+ }
+ ];