From 3661395dff296f1fabc6c3da357a19700411ae1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Tue, 14 Nov 2023 22:20:01 +0100 Subject: [PATCH] fix: invoiceplane nginx config --- hosts/pie/invoiceplane.nix | 6 ++++++ modules/invoiceplane/default.nix | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/hosts/pie/invoiceplane.nix b/hosts/pie/invoiceplane.nix index 8bab641..74fa216 100644 --- a/hosts/pie/invoiceplane.nix +++ b/hosts/pie/invoiceplane.nix @@ -45,6 +45,12 @@ in { createLocally = false; }; + extraConfig = '' + SETUP_COMPLETED=true + DISABLE_SETUP=true + IP_URL=https://invoicing.b12f.io + ''; + poolConfig = { "pm" = "dynamic"; "pm.max_children" = 32; diff --git a/modules/invoiceplane/default.nix b/modules/invoiceplane/default.nix index d7b21c0..da1747f 100644 --- a/modules/invoiceplane/default.nix +++ b/modules/invoiceplane/default.nix @@ -363,20 +363,34 @@ in enable = true; virtualHosts = mapAttrs' (hostName: cfg: ( nameValuePair "${hostName}" { - locations."/" = { - root = "${pkg hostName cfg}"; - extraConfig = '' - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:${config.services.phpfpm.pools."invoiceplane-${hostName}".socket}; - include ${pkgs.nginx}/conf/fastcgi_params; - include ${pkgs.nginx}/conf/fastcgi.conf; + 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; }; }) - ]); }