all repos — nixfiles @ ff1f231cd6dcf3d8e4b76c78bb50becf56dade6f

System and user configuration, managed by nix and home-manager

system/roles/chat.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
  config,
  ...
}:
let
  ts-domain = "fin-marlin.ts.net";
in
{
  age.secrets.open-webui.file = ../../secrets/open-webui.age;

  services.open-webui = {
    enable = true;
    environment = {
      ANONYMIZED_TELEMETRY = "False";
      DO_NOT_TRACK = "True";
      ENABLE_VERSION_UPDATE_CHECK = "False";

      ENABLE_API_KEYS = "True";
      WEBUI_URL = "https://chat.${ts-domain}";
      WEBUI_AUTH_TRUSTED_EMAIL_HEADER = "X-Webauth-Email";
      WEBUI_AUTH_TRUSTED_NAME_HEADER = "X-Webauth-User";
      WEBUI_AUTH = "False";
      CORS_ALLOW_ORIGIN = "https://chat.${ts-domain}";

      OPENAI_API_BASE_URL = "https://openrouter.ai/api/vi";
    };
  };

  services.caddy.virtualHosts = {
    "chat.${ts-domain}" = {
      extraConfig = ''
        bind tailscale/chat
        tailscale_auth
        reverse_proxy localhost:${toString config.services.open-webui.port} {
          header_up X-Webauth-User {http.auth.user.tailscale_login}
          header_up X-Webauth-Email {http.auth.user.tailscale_user}
          header_up X-Webauth-Name {http.auth.user.tailscale_name}
        }
      '';
    };
  };
}