2024-07-16 15:06:08 +03:00
|
|
|
{ config, depot, lib, ... }:
|
2023-03-06 18:58:29 +02:00
|
|
|
|
|
|
|
let
|
2023-08-31 01:55:45 +03:00
|
|
|
inherit (depot.lib.meta) domain;
|
2023-03-06 18:58:29 +02:00
|
|
|
frontendDomain = "consul-remote.internal.${domain}";
|
2023-10-25 00:41:06 +03:00
|
|
|
|
2024-07-16 15:06:08 +03:00
|
|
|
inherit (config.reflection.interfaces.vstub) addr;
|
2023-03-06 18:58:29 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2024-07-17 03:53:36 +03:00
|
|
|
services.nginx.virtualHosts.${frontendDomain} = depot.lib.nginx.vhosts.proxy config.links.consulAgent.url // {
|
2023-10-25 00:41:06 +03:00
|
|
|
listenAddresses = lib.singleton addr;
|
2023-03-06 18:58:29 +02:00
|
|
|
enableACME = false;
|
|
|
|
useACMEHost = "internal.${domain}";
|
|
|
|
};
|
|
|
|
|
|
|
|
consul.services.consul-remote = {
|
|
|
|
unit = "consul";
|
|
|
|
mode = "external";
|
|
|
|
definition = {
|
|
|
|
name = "consul-remote";
|
2023-10-25 00:41:06 +03:00
|
|
|
address = addr;
|
2023-03-06 18:58:29 +02:00
|
|
|
port = 443;
|
|
|
|
checks = [
|
|
|
|
{
|
|
|
|
name = "Frontend";
|
|
|
|
id = "service:consul-remote:frontend";
|
2023-10-25 00:41:06 +03:00
|
|
|
http = "https://${addr}/v1/status/leader";
|
2023-03-06 18:58:29 +02:00
|
|
|
tls_server_name = frontendDomain;
|
2023-06-05 21:25:37 +03:00
|
|
|
header.Host = lib.singleton frontendDomain;
|
2023-03-06 18:58:29 +02:00
|
|
|
interval = "60s";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "Backend";
|
|
|
|
id = "service:consul-remote:backend";
|
2024-07-17 03:53:36 +03:00
|
|
|
http = "${config.links.consulAgent.url}/v1/status/leader";
|
2023-03-06 18:58:29 +02:00
|
|
|
interval = "30s";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|