From dd275ebb6da90b875555e075278559e6e408fb96 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 16 Jun 2024 19:45:30 +0200 Subject: [PATCH] fix: invoiceplane nginx config Co-authored-by: b12f --- modules/invoiceplane/default.nix | 36 +++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/invoiceplane/default.nix b/modules/invoiceplane/default.nix index 52be0f23..ca3fafeb 100644 --- a/modules/invoiceplane/default.nix +++ b/modules/invoiceplane/default.nix @@ -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; + }; + }) + ]); }