feat(proxy): add /health endpoint for liveness checks#9
Merged
Conversation
Mount a local http.ServeMux on wardgate-proxy that serves GET /health
with a small JSON payload (status, service, version) and falls through
to the existing reverse-proxy handler for every other path. The endpoint
performs no upstream call and requires no agent key, so callers on the
local listen socket can confirm wardgate-proxy is on path before
forwarding real traffic.
Use case: sandbox sidecars that gate boot on wardgate-proxy readiness
can now waitForPort(80, { mode: "http", path: "/health" }) instead of
relying on a TCP probe that succeeds the instant the socket binds.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
-e
Signed-off-by: Emre Tinaztepe <emre@binalyze.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a local
GET /healthendpoint towardgate-proxyso sidecars (e.g. the Fleet sandbox boot sequence) can confirm the proxy is up and serving HTTP before it starts trusting the proxy with sealed credentials.What it does
http.ServeMuxinwardgate-proxythat handlesGET /healthlocally with a small JSON payload ({"status":"ok","service":"wardgate-proxy","version":"…"}).ReverseProxyhandler — no behavior change for real traffic.HEAD /healthreturns 200 with no body; non-GET/HEAD methods get 405 withAllow: GET, HEAD.Why
Fleet's sandbox boot currently launches
wardgate-proxyand immediately moves on to start OpenCode with sealed env vars. If the proxy never binds — or binds and then crashes on its first request — OpenCode's first sealed call goes to a dead socket and the failure surfaces in confusing ways. With this endpoint, the boot can do:so wardgate-proxy readiness is a hard precondition for downstream steps. Same pattern recommended in Fleet's pre-pentest audit F-06 fix-up (startup self-test that confirms the proxy is on path).
Tests
TestHealthHandler_ReturnsOK— 200 +application/json+ payload shape.TestHealthHandler_HEADReturnsNoBody— HEAD returns 200, empty body.TestHealthHandler_RejectsNonGET— POST returns 405 withAllow: GET, HEAD.TestBuildMux_HealthBypassesProxy—/healthis served locally and never hits the upstream.TestBuildMux_NonHealthGoesToProxy— every other path still flows through the reverse-proxy with the agent's JWT injected.Test plan
go test ./cmd/wardgate-proxy/... -count=1passes locally/healthtraffic)/healthis acceptable as a reserved path (no real upstream that wardgate fronts uses/healthas a meaningful route in our deployments)🤖 Generated with Claude Code