From d9013cca0a84b490b6ed407edb4dc58e6217225e Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Wed, 13 May 2026 12:38:27 -0500 Subject: [PATCH] feat(ollama): implement hybrid security model and initialize llama3 - Reconfigured Traefik labels to support dual-router logic: - Priority 100: Token-based bypass via 'X-Ollama-Key' header for automation. - Priority 50: Standard Authelia SSO protection for browser access. - Documented the 'Trusted Payload' flow in docs/usability.md. - Initialized the service by pulling the 'llama3' model to the shared volume. --- apps/ollama/docker-compose.yml | 26 ++++++++++++++++++++------ docs/usability.md | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/apps/ollama/docker-compose.yml b/apps/ollama/docker-compose.yml index 3591dc1..73705a7 100644 --- a/apps/ollama/docker-compose.yml +++ b/apps/ollama/docker-compose.yml @@ -16,12 +16,26 @@ services: - proxy-net labels: - "traefik.enable=true" - - "traefik.http.routers.ollama.rule=Host(`ollama.arch-services.mywire.org`)" - - "traefik.http.routers.ollama.entrypoints=websecure" - - "traefik.http.routers.ollama.tls.certresolver=myresolver" - - "traefik.http.services.ollama.loadbalancer.server.port=11434" - - "traefik.http.services.ollama.loadbalancer.healthcheck.path=/api/tags" - - "traefik.http.services.ollama.loadbalancer.healthcheck.interval=10s" + # Router 1: API/Automation (Token-based) + - "traefik.http.routers.ollama-api.rule=Host(`ollama.arch-services.mywire.org`) && Header(`X-Ollama-Key`, `sk-ollama-hardened-hub-2026`)" + - "traefik.http.routers.ollama-api.entrypoints=websecure" + - "traefik.http.routers.ollama-api.tls.certresolver=myresolver" + - "traefik.http.routers.ollama-api.priority=100" + - "traefik.http.routers.ollama-api.service=ollama-svc" + + # Router 2: Browser/Standard (Authelia Protected) + - "traefik.http.routers.ollama-browser.rule=Host(`ollama.arch-services.mywire.org`)" + - "traefik.http.routers.ollama-browser.entrypoints=websecure" + - "traefik.http.routers.ollama-browser.tls.certresolver=myresolver" + - "traefik.http.routers.ollama-browser.middlewares=authelia-auth@docker" + - "traefik.http.routers.ollama-browser.priority=50" + - "traefik.http.routers.ollama-browser.service=ollama-svc" + + # Shared Service + - "traefik.http.services.ollama-svc.loadbalancer.server.port=11434" + - "traefik.http.services.ollama-svc.loadbalancer.healthcheck.path=/api/tags" + - "traefik.http.services.ollama-svc.loadbalancer.healthcheck.interval=10s" + volumes: ollama_data: diff --git a/docs/usability.md b/docs/usability.md index b6d177a..e887fd5 100644 --- a/docs/usability.md +++ b/docs/usability.md @@ -47,3 +47,21 @@ To add a new service to the Hub: ## 📝 Logging Real-time logs can be viewed via **Dozzle** at `https://logs.arch-services.mywire.org`. This is preferred over `docker logs` for quick debugging across multiple containers. + +## 🤖 Ollama API & Automation (Trusted Payload) +Ollama uses a hybrid security model to allow both browser use and automated tools: + +### Browser Use +Accessing `https://ollama.arch-services.mywire.org` directly will prompt for **Authelia SSO** login. + +### API & CLI Bypass +For scripts, cron jobs, or terminal use, you can bypass SSO by including the `X-Ollama-Key` header. +- **Header**: `X-Ollama-Key: sk-ollama-hardened-hub-2026` + +**Example (curl):** +```bash +curl https://ollama.arch-services.mywire.org/api/generate \ + -H "X-Ollama-Key: sk-ollama-hardened-hub-2026" \ + -d '{"model": "llama3", "prompt": "hi"}' +``` +