Repository navigation
fix(provision): plain HTTP to a private-network IP reaches Trinity (#3821) - #3833
Conversation
…stead of redirecting (#3821) Caddy's automatic HTTP->HTTPS redirects for the on-demand wildcard site are routed by host pattern and run ahead of the user's `http://` block. `https://*.*.*.*` matches a dotted IPv4 host, so `http://<tailnet-ip>` got a 308 before the `@private remote_ip` handler saw it; only a dotless MagicDNS name reached it. When PRIVATE_NETWORK_CIDRS is set, the render now adds `auto_https disable_redirects`, leaving the `http://` block as the only route on :80, and its fallback redirect is 308 (the code the automatic redirects used). Caddy answers ACME HTTP challenges ahead of every route, so certificate issuance is unaffected. With the variable unset the file renders byte-identical to before. Fixes #3821 Co-Authored-By: Claude Opus 5.5 <[email protected]>
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Reviewed against Caddy 2.11.4 (the pinned version, not caddy:2). I rendered both configs with the test's _render harness and sent real requests at port 80. From inside the CIDR, private IP, public IP, domain and dotless Host all reach the upstream over plain HTTP. From outside, everything still gets a 308 to https, POST included, and so do a forged Host: 100.64.0.1 and a forged X-Forwarded-For. With the variable unset the render is byte-identical to dev. The ACME HTTP challenge runs ahead of the routes (server.go:384 at v2.11.4), so certificates aren't affected.
Teeth: the new test fails on the merge-base start.sh and when the _auto_https line is removed. It does pass if the rendered directive is commented out (# auto_https disable_redirects), because it matches the text rather than Caddy's behaviour. Could you add a check that runs the render through caddy adapt and asserts disable_redirects in the JSON, skipped when caddy isn't installed? Not blocking.
Approving. Please still tick the droplet check before merge.
Summary
PRIVATE_NETWORK_CIDRSset,http://<private-ip>returned a 308 to HTTPS instead of reaching the@privatehandler. Caddy's automatic redirects for the on-demand wildcard site (https://*.*.*.*matches a dotted IPv4 host) run ahead of thehttp://block. Only a dotless MagicDNS name got through.auto_https disable_redirects, so thehttp://block is the only route on :80. Its fallback redirect is now308(waspermanent, which is 301), the code the automatic redirects used, so a POST from outside the network keeps its method.Caddy answers ACME HTTP challenges ahead of every route (
modules/caddyhttp/server.go, v2.11.7,HandleHTTPChallenge), so certificate issuance and renewal are unaffected.Changes
scripts/deploy/start.sh:provision_caddyfiletests/unit/test_2692_private_network_access.py: private render carriesdisable_redirects+ 308 fallback; unset render has noauto_httpsand no extra global linedocs/user-docs/guides/deploying/hardening.md: the IP and the MagicDNS name both workTest Plan
cd tests && pytest unit/test_2692_private_network_access.py unit/test_2380_provision_single_source.py unit/test_3004_aws_provision.py unit/test_2281_marketplace_build_standard.py: 72 passed, 5 skipped. The new tests fail against the unfixedstart.sh.caddy:2image), fed the Caddyfilestart.shactually renders, with client containers inside and outside the CIDR:caddy adaptaccepts both the unset and the set renderPRIVATE_NETWORK_CIDRSset:--caddy-only, thencurl -i http://<private-ip>/api/setup/statusfrom inside the CIDR → 200; from outside → redirect;https://<public-ip>unchangedUpgrade note
Instances that already have
PRIVATE_NETWORK_CIDRSset get the fix only after re-rendering:sudo ./scripts/deploy/start.sh --provision --cloud <cloud> --caddy-onlyFixes #3821
🤖 Generated with Claude Code