feat: fuck nginx

This commit is contained in:
Nick 2024-10-07 14:49:28 -05:00
parent 620aebfd11
commit 36b3b2cff4
2 changed files with 18 additions and 48 deletions

View file

@ -83,6 +83,4 @@ in {
sopsSecrets sopsSecrets
); );
}; };
users.users.nginx.extraGroups = ["acme"];
users.groups.acme.members = ["nginx"];
} }

View file

@ -2,89 +2,61 @@
inherit (flake.config.people) user0; inherit (flake.config.people) user0;
inherit (flake.config.people.user.${user0}) domain; inherit (flake.config.people.user.${user0}) domain;
inherit (flake.config.system.device) server wildcard; inherit (flake.config.system.device) server wildcard;
inherit (flake.config.service.instance) ollama acme; inherit (flake.config.service.instance.ollama) paths ports subdomain name ssl;
localhost = wildcard.ip.address0; localhost = wildcard.ip.address0;
host = "${ollama.subdomain}.${domain.url0}"; host = "${subdomain}.${domain.url0}";
in { in {
services = { services = {
ollama = { ollama = {
acceleration = false; acceleration = false;
enable = true; enable = true;
group = ollama.name; group = name;
host = "http://${localhost}"; host = "http://${localhost}";
port = ollama.ports.port1; port = ports.port1;
user = ollama.name; user = name;
}; };
open-webui = { open-webui = {
enable = true; enable = true;
host = localhost; host = localhost;
port = ollama.ports.port0; port = ports.port0;
environment = { environment = {
ENABLE_OLLAMA_API = "True"; ENABLE_OLLAMA_API = "True";
ANONYMIZED_TELEMETRY = "False"; ANONYMIZED_TELEMETRY = "False";
DO_NOT_TRACK = "True"; DO_NOT_TRACK = "True";
SCARF_NO_ANALYTICS = "True"; SCARF_NO_ANALYTICS = "True";
OLLAMA_BASE_URL = "http://${localhost}:${toString ollama.ports.port1}"; OLLAMA_BASE_URL = "http://${localhost}:${toString ports.port1}";
WEBUI_AUTH = "True"; WEBUI_AUTH = "True";
}; };
}; };
# caddy = { caddy = {
# virtualHosts = { virtualHosts = {
# ${host} = { ${host} = {
# extraConfig = ''
# reverse_proxy ${localhost}:${toString ports.port0}
# tls ${ollama.ssl.cert} ${ollama.ssl.key}
# '';
# };
# };
# };
nginx = {
enable = true;
virtualHosts.${host} = {
onlySSL = true;
sslCertificate = ollama.ssl.cert;
sslCertificateKey = ollama.ssl.key;
listen = [
{
addr = localhost;
port = 4443;
ssl = true;
}
];
locations."/" = {
proxyPass = "http://${localhost}:${toString ollama.ports.port0}";
extraConfig = '' extraConfig = ''
proxy_set_header Host $host; reverse_proxy ${localhost}:${toString ports.port0}
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; tls ${ssl.cert} ${ssl.key}
proxy_set_header X-Forwarded-Proto $scheme;
''; '';
}; };
}; };
}; };
}; };
fileSystems."/var/lib/${ollama.name}" = { fileSystems."/var/lib/${name}" = {
device = ollama.paths.path0; device = paths.path0;
fsType = "none"; fsType = "none";
options = ["bind"]; options = ["bind"];
depends = [server.storage0.mount]; depends = [server.storage0.mount];
}; };
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = ["Z ${paths.path0} 0755 ${name} ${name} -"];
"Z ${ollama.paths.path0} 0755 ${ollama.name} ${ollama.name} -"
"Z ${acme.paths.path0}/${host} 0755 ${ollama.name} ${ollama.name} -"
];
networking = { networking = {
firewall = { firewall = {
allowedTCPPorts = [ allowedTCPPorts = [
ollama.ports.port0 ports.port0
ollama.ports.port1 ports.port1
]; ];
}; };
}; };