cleaned up duplicated code
This commit is contained in:
parent
e393a4481b
commit
30cff89a50
@ -53,59 +53,8 @@ let
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
proxy = locations: {
|
||||
inherit locations;
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
http2 = true;
|
||||
};
|
||||
proxyReverse =
|
||||
cfg:
|
||||
proxy {
|
||||
"/" = {
|
||||
proxyPass = "http://${cfg.ip}:${toString cfg.port}/";
|
||||
proxyWebsockets = cfg.enableSocket;
|
||||
};
|
||||
};
|
||||
proxyReverseFix =
|
||||
cfg:
|
||||
let
|
||||
useLocalhost = cfg.hostName == config.networking.hostName;
|
||||
localHeaders = ''
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
'';
|
||||
in
|
||||
proxyReverse cfg
|
||||
// {
|
||||
extraConfig = ''
|
||||
${if useLocalhost then localHeaders else ""}
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
'';
|
||||
};
|
||||
proxyReversePrivate =
|
||||
cfg:
|
||||
proxyReverse cfg
|
||||
// {
|
||||
extraConfig = ''
|
||||
ssl_verify_client on;
|
||||
ssl_client_certificate ${cfg.certPath};
|
||||
error_page 403 /403.html;
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit
|
||||
mkOptions
|
||||
proxy
|
||||
proxyReverse
|
||||
proxyReverseFix
|
||||
proxyReversePrivate
|
||||
;
|
||||
inherit mkOptions;
|
||||
mkServerOptions = mkOptions;
|
||||
}
|
||||
|
||||
@ -148,28 +148,6 @@ in
|
||||
if shellType == "bash" then { initExtra = bashContent; } else { initContent = zshContent; };
|
||||
mergeAliases = baseAliases: extraAliases: baseAliases // extraAliases;
|
||||
importDotfile = path: import path;
|
||||
mkScriptOptions = lib: {
|
||||
enable = lib.mkEnableOption "Whether to enable this script";
|
||||
install = lib.mkEnableOption "Whether to install the script package";
|
||||
service = lib.mkEnableOption "Whether to enable the script service";
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name of the script.";
|
||||
};
|
||||
timer = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "*:0";
|
||||
description = "Systemd timer schedule.";
|
||||
};
|
||||
description = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Description of the service.";
|
||||
};
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
description = "Package containing the executable script.";
|
||||
};
|
||||
};
|
||||
getServicesWithNativeFirewall =
|
||||
config: blacklist:
|
||||
config.my.servers
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user