mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
51 lines
1.2 KiB
Nix
51 lines
1.2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit (lib.modules) mkIf mkDefault;
|
|
inherit (config.services) loki;
|
|
name.shortServer = mkDefault "logs";
|
|
upstreamName = "loki'access";
|
|
in {
|
|
config.services.nginx = {
|
|
# TODO: gRPC port?
|
|
upstreams'.${upstreamName}.servers = {
|
|
local = {
|
|
enable = mkDefault loki.enable;
|
|
addr = mkDefault "localhost";
|
|
port = mkIf loki.enable (mkDefault loki.configuration.server.http_listen_port);
|
|
};
|
|
service = {upstream, ...}: {
|
|
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
|
accessService = {
|
|
name = "loki";
|
|
};
|
|
};
|
|
};
|
|
virtualHosts = let
|
|
copyFromVhost = mkDefault "loki";
|
|
vouch.enable = mkDefault true;
|
|
locations = {
|
|
"/" = {
|
|
proxy.enable = true;
|
|
};
|
|
};
|
|
in {
|
|
loki = {
|
|
inherit name locations vouch;
|
|
proxy.upstream = mkDefault upstreamName;
|
|
};
|
|
loki'local = {
|
|
inherit name locations vouch;
|
|
ssl.cert = {
|
|
inherit copyFromVhost;
|
|
};
|
|
proxy = {
|
|
inherit copyFromVhost;
|
|
};
|
|
local.enable = mkDefault true;
|
|
};
|
|
};
|
|
};
|
|
}
|