fix(agent): hairpin DNAT so a colocated edge proxy reaches sandboxed apps #135
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!135
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/sandbox-hairpin-ingress"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
EnsureIngress(PR #91) only installs a PREROUTING DNAT matching-i <host-iface>— traffic arriving from outside the host. But Caddy runs on hetzner-master itself, and its reverse-proxy connections to the node's own public IP are locally originated: they traverse the nat OUTPUT chain, never PREROUTING. Result: the DNAT is bypassed and the connection lands on the host port, where nothing listens in sandbox mode — a sandboxed app can be perfectly healthy yet unreachable through its own node's edge.Found live during the classback cutover: edge health checks kept returning 200 but were being served by the old workaround unit, not the sandbox. Stopping the workaround would have taken the edge dark.
Fix
Add the standard hairpin rule per ingress port (mirrors Docker's approach):
--dst-type LOCALcovers any host-local address (public IP, Tailscale IP) without hardcoding one. Loopback is excluded because DNATing 127.0.0.1 traffic into the veth produces a martian source withoutroute_localnet.TDD: expectations extended first (red), then the rule (green).
go test ./internal/sandbox/,go build ./...,go vetall clean.Operator state
The equivalent rule is hand-applied on hetzner-master for classback:8095 (verified serving: edge requests log from the sandboxed unit; workaround stopped+disabled).
EnsureIngressis check-before-add with the identical spec, so the next deploy/agent-roll will not duplicate it. This code takes fleet effect on the next agent release (0.1.36).🤖 Generated with Claude Code
🤖 Bob subscription review — APPROVE: Adds OUTPUT chain DNAT rule for colocated proxy hairpin case, excludes loopback correctly, updates tests consistently including index shifts and count expectations.