Revert "refactor(nixos): inline reverse proxy HTTP helpers"
This reverts commit 8bfe6de4ea.
This commit is contained in:
@@ -9,34 +9,30 @@ let
|
|||||||
|
|
||||||
mkRegistryPath = registryName: host: entry: "registry.${registryName}.${host}.${entry}";
|
mkRegistryPath = registryName: host: entry: "registry.${registryName}.${host}.${entry}";
|
||||||
|
|
||||||
mkUdpStream = host: entry: port:
|
mkBackend = address: route: "http://${address}:${toString route.port}";
|
||||||
|
|
||||||
|
mkVirtualHost = host: entry:
|
||||||
let
|
let
|
||||||
compositeEntry = registry.join host entry;
|
compositeEntry = registry.join host entry;
|
||||||
|
route = compositeEntry.route;
|
||||||
address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}");
|
address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}");
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit host entry port address;
|
inherit host entry;
|
||||||
|
name = route.domain;
|
||||||
|
value = {
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
locations."/".proxyPass = mkBackend address route;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
generatedVirtualHostList = lib.concatLists (
|
generatedVirtualHostList = lib.concatLists (
|
||||||
lib.mapAttrsToList (
|
lib.mapAttrsToList (
|
||||||
host: routes:
|
host: routes:
|
||||||
lib.mapAttrsToList (
|
lib.mapAttrsToList (entry: _route: mkVirtualHost host entry) (
|
||||||
entry: route:
|
lib.filterAttrs (_entry: route: route.port != null) routes
|
||||||
let
|
)
|
||||||
compositeEntry = registry.join host entry;
|
|
||||||
address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}");
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit host entry;
|
|
||||||
name = route.domain;
|
|
||||||
value = {
|
|
||||||
forceSSL = true;
|
|
||||||
enableACME = true;
|
|
||||||
locations."/".proxyPass = "http://${address}:${toString route.port}";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
) (lib.filterAttrs (_entry: route: route.port != null) routes)
|
|
||||||
) registry.route
|
) registry.route
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -66,6 +62,15 @@ let
|
|||||||
else
|
else
|
||||||
lib.listToAttrs generatedVirtualHostList;
|
lib.listToAttrs generatedVirtualHostList;
|
||||||
|
|
||||||
|
mkUdpStream = host: entry: port:
|
||||||
|
let
|
||||||
|
compositeEntry = registry.join host entry;
|
||||||
|
address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}");
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit host entry port address;
|
||||||
|
};
|
||||||
|
|
||||||
generatedUdpStreams = lib.concatLists (
|
generatedUdpStreams = lib.concatLists (
|
||||||
lib.mapAttrsToList (
|
lib.mapAttrsToList (
|
||||||
host: routes:
|
host: routes:
|
||||||
|
|||||||
Reference in New Issue
Block a user