mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
nixos/invoiceplane: add nginx as a webserver option for invoiceplane
Getting the vhost to play nice with phpfpm was done by following this community post: https://community.invoiceplane.com/t/topic/2654
This commit is contained in:
parent
ffe76ea5e2
commit
7c3ecbdce9
@ -252,11 +252,11 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
options.webserver = mkOption {
|
options.webserver = mkOption {
|
||||||
type = types.enum [ "caddy" ];
|
type = types.enum [ "caddy" "nginx" ];
|
||||||
default = "caddy";
|
default = "caddy";
|
||||||
|
example = "nginx";
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Which webserver to use for virtual host management. Currently only
|
Which webserver to use for virtual host management.
|
||||||
caddy is supported.
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -390,5 +390,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 ${config.services.nginx.package}/conf/fastcgi_params;
|
||||||
|
include ${config.services.nginx.package}/conf/fastcgi.conf;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)) eachSite;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -27,17 +27,41 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
invoiceplane_nginx = { ... }: {
|
||||||
|
services.invoiceplane.webserver = "nginx";
|
||||||
|
services.invoiceplane.sites = {
|
||||||
|
"site1.local" = {
|
||||||
|
database.name = "invoiceplane1";
|
||||||
|
database.createLocally = true;
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
"site2.local" = {
|
||||||
|
database.name = "invoiceplane2";
|
||||||
|
database.createLocally = true;
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
|
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
start_all()
|
||||||
|
|
||||||
invoiceplane_caddy.wait_for_unit("caddy")
|
invoiceplane_caddy.wait_for_unit("caddy")
|
||||||
invoiceplane_caddy.wait_for_open_port(80)
|
invoiceplane_nginx.wait_for_unit("nginx")
|
||||||
invoiceplane_caddy.wait_for_open_port(3306)
|
|
||||||
|
|
||||||
site_names = ["site1.local", "site2.local"]
|
site_names = ["site1.local", "site2.local"]
|
||||||
|
|
||||||
|
machines = [invoiceplane_caddy, invoiceplane_nginx]
|
||||||
|
|
||||||
|
for machine in machines:
|
||||||
|
machine.wait_for_open_port(80)
|
||||||
|
machine.wait_for_open_port(3306)
|
||||||
|
|
||||||
for site_name in site_names:
|
for site_name in site_names:
|
||||||
machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}")
|
machine.wait_for_unit(f"phpfpm-invoiceplane-{site_name}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user