Skip to content

feat: restore ollama_tailnet fish function - #45

Merged
wu-json merged 4 commits into
mainfrom
feat/ollama-tailnet
Nov 1, 2026
Merged

wu-json merged 4 commits into
mainfrom
feat/ollama-tailnet

Conversation

@wu-json

@wu-json wu-json commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Restores the ollama_tailnet fish function (removed in 9aef945). It serves the host's Ollama at https://ollama.<tailnet>.ts.net by running a Tailscale container in OrbStack that joins the tailnet as its own ollama node.

tailnet --HTTPS--> Tailscale container (Serve :443) --> Caddy (:8080, rewrites Host) --> host Ollama (127.0.0.1:11434)

Changes from the previous version

  • Ollama stays off the LAN. If the function starts Ollama, it binds to 127.0.0.1 instead of 0.0.0.0 (OrbStack containers can still reach the host's localhost).
  • Host header rewrite. Loopback-bound Ollama returns 403 for non-localhost Host headers, and Tailscale Serve forwards the original *.ts.net Host. A Caddy container sharing the Tailscale container's network rewrites it.
  • Ctrl-c actually stops it. The old fish --on-signal SIGINT handler never fired (ctrl-c goes to the foreground process, not fish), so the container kept running. docker attach --sig-proxy now runs in the foreground right after start, with startup checks in a background process, so ctrl-c at any point stops and removes both containers.
  • Overlapping runs are safe. Containers are tracked by ID, so a second up can't be removed by the first one's cleanup.
  • Real readiness checks. Fails with an actionable message if the tailnet has HTTPS certificates disabled or the serve config isn't applied (printing the last container log lines), and prints the node's actual DNS name (e.g. ollama-1 if ollama is taken).
  • Images stay current. Pulls tailscale/tailscale:latest and caddy:2 on each start, falling back to cached images if the pull fails.

Testing

End to end in an interactive fish under a pty, against a loopback-only Ollama:

  • ollama_tailnet starts, HTTPS request over the tailnet returns {"version": ...}, a real ctrl-c keystroke removes both containers.
  • Starting a second up while the first runs: the first stops cleanly, the second keeps serving.
  • Confirmed separately: loopback Ollama returns 403 for a *.ts.net Host, and Tailscale Serve preserves the incoming Host.

Reviewed with Codex over 4 rounds; the last round had no findings.

🤖 Generated with Claude Code

wu-json and others added 4 commits November 1, 2026 09:35
Brings back ollama_tailnet (removed in 9aef945), which serves the host's
Ollama at https://ollama.<tailnet>.ts.net through a Tailscale container.

Changes from the previous version:
- Ctrl-c now stops the container. The old fish SIGINT handler never fired
  because the signal goes to the foreground process, so the container kept
  running. It now waits with `docker attach --sig-proxy`, which forwards
  ctrl-c to the container.
- Pulls tailscale/tailscale:latest on each start so the node doesn't drift
  behind, falling back to the cached image if the pull fails.
- Trimmed comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Start Ollama on 127.0.0.1 instead of 0.0.0.0. OrbStack containers can
  reach the host's localhost, so the LAN never needs access.
- Attach to the container right after starting it and run the startup
  checks in a background process, so ctrl-c at any point stops the
  container.
- Fail with an actionable message if the tailnet has HTTPS certificates
  disabled or the serve config isn't applied, instead of reporting success.
- Print the node's real DNS name (Tailscale may rename it, e.g. ollama-1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Require a non-empty CertDomains list. Tailscale reports
  "CertDomains": null when HTTPS is disabled, which passed the old check.
- Track the container by the ID from docker run, so a second `up` in
  another terminal can't have its container removed by the first one's
  cleanup.
- Show the last few container log lines before removing it on failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uests

Ollama bound to 127.0.0.1 rejects requests whose Host header isn't
localhost-like (403), and Tailscale Serve forwards the original
ollama.<tailnet>.ts.net Host. Route Serve through a Caddy container that
shares the Tailscale container's network and rewrites Host before
proxying to the host's Ollama.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wu-json
wu-json merged commit 934c476 into main Nov 1, 2026
1 check passed
@wu-json
wu-json deleted the feat/ollama-tailnet branch November 1, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant