fix: invoiceplane nginx config

Co-authored-by: b12f <b12f@noreply.git.pub.solar>
This commit is contained in:
teutat3s 2024-06-16 19:45:30 +02:00
parent 6a46d98662
commit dd275ebb6d
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1

View file

@ -241,7 +241,7 @@ in
};
options.webserver = mkOption {
type = types.enum [ "caddy" ];
type = types.enum [ "caddy" "nginx" ];
default = "caddy";
description = lib.mdDoc ''
Which webserver to use for virtual host management. Currently only
@ -373,5 +373,39 @@ in
};
})
(mkIf (cfg.webserver == "nginx") {
services.nginx = {
enable = true;
virtualHosts = mapAttrs' (hostName: cfg: (
nameValuePair "${hostName}" {
root = "${pkg hostName cfg}";
extraConfig = ''
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
'';
locations = {
"/setup".extraConfig = ''
rewrite ^(.*)$ http://${hostName}/ redirect;
'';
"~ .php$" = {
extraConfig = ''
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:${config.services.phpfpm.pools."invoiceplane-${hostName}".socket};
include ${pkgs.nginx}/conf/fastcgi_params;
include ${pkgs.nginx}/conf/fastcgi.conf;
'';
};
};
}
)) eachSite;
};
})
]);
}