cluster/services/ways: support internal services properly
This commit is contained in:
parent
5d26d45916
commit
e81aad5619
3 changed files with 35 additions and 13 deletions
|
@ -11,6 +11,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
dns.records = lib.mapAttrs'
|
dns.records = lib.mapAttrs'
|
||||||
(_: cfg: lib.nameValuePair cfg.dnsRecord.name ({ ... }: { imports = [ cfg.dnsRecord.value ]; }))
|
(_: cfg: lib.nameValuePair cfg.dnsRecord.name ({ ... }: {
|
||||||
|
imports = [ cfg.dnsRecord.value ];
|
||||||
|
root = cfg.domainSuffix;
|
||||||
|
}))
|
||||||
config.ways;
|
config.ways;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
let
|
let
|
||||||
externalWays = lib.filterAttrs (_: cfg: !cfg.internal) cluster.config.ways;
|
externalWays = lib.filterAttrs (_: cfg: !cfg.internal) cluster.config.ways;
|
||||||
|
|
||||||
|
internalWays = lib.filterAttrs (_: cfg: cfg.internal) cluster.config.ways;
|
||||||
|
|
||||||
consulServiceWays = lib.filterAttrs (_: cfg: cfg.useConsul) cluster.config.ways;
|
consulServiceWays = lib.filterAttrs (_: cfg: cfg.useConsul) cluster.config.ways;
|
||||||
in
|
in
|
||||||
|
|
||||||
|
@ -14,6 +16,7 @@ in
|
||||||
imports = [
|
imports = [
|
||||||
cfg.extras
|
cfg.extras
|
||||||
{
|
{
|
||||||
|
listenAddresses = lib.mkIf cfg.internal [ config.reflection.interfaces.vstub.addr ];
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = !cfg.internal && !cfg.wildcard;
|
enableACME = !cfg.internal && !cfg.wildcard;
|
||||||
useACMEHost = lib.mkMerge [
|
useACMEHost = lib.mkMerge [
|
||||||
|
@ -84,7 +87,8 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
consul.services.ways-proxy = {
|
consul.services = {
|
||||||
|
ways-proxy = {
|
||||||
unit = "nginx";
|
unit = "nginx";
|
||||||
mode = "external";
|
mode = "external";
|
||||||
definition = {
|
definition = {
|
||||||
|
@ -98,4 +102,19 @@ in
|
||||||
tags = lib.attrNames externalWays;
|
tags = lib.attrNames externalWays;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
ways-proxy-internal = {
|
||||||
|
unit = "nginx";
|
||||||
|
mode = "external";
|
||||||
|
definition = {
|
||||||
|
name = "ways-proxy-internal";
|
||||||
|
address = config.reflection.interfaces.vstub.addr;
|
||||||
|
port = 443;
|
||||||
|
checks = lib.singleton {
|
||||||
|
interval = "60s";
|
||||||
|
tcp = "127.0.0.1:80";
|
||||||
|
};
|
||||||
|
tags = lib.attrNames internalWays;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ with lib;
|
||||||
description = "DNS record value for this Way.";
|
description = "DNS record value for this Way.";
|
||||||
type = types.deferredModule;
|
type = types.deferredModule;
|
||||||
default = {
|
default = {
|
||||||
consulService = "${name}.ways-proxy";
|
consulService = "${name}.${if config.internal then "ways-proxy-internal" else "ways-proxy"}";
|
||||||
rewrite.type = lib.mkIf config.wildcard "regex";
|
rewrite.type = lib.mkIf config.wildcard "regex";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue