-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathai.nix
98 lines (88 loc) · 2.38 KB
/
ai.nix
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
config,
globals,
...
}:
let
openWebuiDomain = "chat.${globals.domains.me}";
in
{
microvm.mem = 1024 * 16;
microvm.vcpu = 20;
wireguard.proxy-sentinel = {
client.via = "sentinel";
firewallRuleForNode.sentinel.allowedTCPPorts = [ config.services.open-webui.port ];
};
networking.firewall.allowedTCPPorts = [ config.services.ollama.port ];
environment.persistence."/state".directories = [
{
directory = "/var/lib/private/ollama";
mode = "0700";
}
{
directory = "/var/lib/private/open-webui";
mode = "0700";
}
];
services.ollama = {
enable = true;
host = "0.0.0.0";
port = 11434;
};
services.open-webui = {
enable = true;
host = "0.0.0.0";
port = 11222;
environment = {
SCARF_NO_ANALYTICS = "True";
DO_NOT_TRACK = "True";
ANONYMIZED_TELEMETRY = "False";
ENABLE_COMMUNITY_SHARING = "False";
ENABLE_ADMIN_EXPORT = "False";
OLLAMA_BASE_URL = "http://localhost:11434";
TRANSFORMERS_CACHE = "/var/lib/open-webui/.cache/huggingface";
WEBUI_AUTH = "False";
ENABLE_SIGNUP = "False";
WEBUI_AUTH_TRUSTED_EMAIL_HEADER = "X-Email";
DEFAULT_USER_ROLE = "user";
};
};
globals.services.open-webui.domain = openWebuiDomain;
globals.monitoring.http.ollama = {
url = config.services.open-webui.environment.OLLAMA_BASE_URL;
expectedBodyRegex = "Ollama is running";
network = "local-${config.node.name}";
};
nodes.sentinel = {
services.nginx = {
upstreams.open-webui = {
servers."${config.wireguard.proxy-sentinel.ipv4}:${toString config.services.open-webui.port}" = { };
extraConfig = ''
zone open-webui 64k;
keepalive 2;
'';
monitoring = {
enable = true;
expectedBodyRegex = "Open WebUI";
};
};
virtualHosts.${openWebuiDomain} = {
forceSSL = true;
useACMEWildcardHost = true;
oauth2 = {
enable = true;
allowedGroups = [ "access_openwebui" ];
X-Email = "\${upstream_http_x_auth_request_preferred_username}@${globals.domains.personal}";
};
extraConfig = ''
client_max_body_size 128M;
'';
locations."/" = {
proxyPass = "http://open-webui";
proxyWebsockets = true;
X-Frame-Options = "SAMEORIGIN";
};
};
};
};
}