mirror of
https://codeberg.org/puppe/financier-nix.git
synced 2025-12-20 00:12:17 +01:00
Make Caddy the default web server
This commit is contained in:
parent
98ab6e58f1
commit
e71e35cb55
1 changed files with 32 additions and 6 deletions
30
module.nix
30
module.nix
|
|
@ -13,20 +13,46 @@ in
|
||||||
hostName = mkOption {
|
hostName = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = ''
|
description = ''
|
||||||
Name for the nginx virtual host.
|
Name for the virtual host for the web server.
|
||||||
'';
|
'';
|
||||||
example = "example.org";
|
example = "example.org";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
server = mkOption {
|
||||||
|
type = types.enum [ "nginx" "caddy" ];
|
||||||
|
description = ''
|
||||||
|
The web server to be used for serving Financier. Either "nginx"
|
||||||
|
or "caddy".
|
||||||
|
'';
|
||||||
|
default = "caddy";
|
||||||
|
example = "example.org";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||||
|
|
||||||
services.nginx.virtualHosts."${cfg.hostName}" = {
|
services.nginx = mkIf (cfg.server == "nginx") {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
virtualHosts."${cfg.hostName}" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
root = financier-dist;
|
root = financier-dist;
|
||||||
locations."/".tryFiles = "$uri $uri/ /index.html";
|
locations."/".tryFiles = "$uri $uri/ /index.html";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.caddy = mkIf (cfg.server == "caddy") {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
config = ''
|
||||||
|
${cfg.hostName} {
|
||||||
|
root * ${financier-dist}
|
||||||
|
file_server
|
||||||
|
try_files {path} {path}/ /index.html
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue