Repository navigation
Add opt-in HTTP to HTTPS redirect for services - #129
Merged
Merged
Conversation
docktail.service.http-redirect=true (also per index) makes port 80 of an
https service answer with a 308 redirect to its HTTPS endpoint, so
http:// URLs and bare MagicDNS names no longer hang.
The reconciler derives the port-80 endpoint from the label, so conflict
detection, Service definition port sync and stale-endpoint removal work
unchanged. The tailscale CLI has no redirect flag yet, so that one
listener is written through tailscaled's LocalAPI serve-config endpoint
with an If-Match ETag, keeping every other field of the config as is.
The target names the full MagicDNS FQDN instead of ${HOST}, which would
keep a short name the certificate does not cover (tailscale#21683).
Redirects need tailscaled 1.92+; older daemons and tailnets without
MagicDNS get a warning and keep serving HTTPS without the redirect.
Lint: check the LocalAPI response Body.Close errors, use a tagged switch on the status code, and build the fake LocalAPI's ETag with strconv instead of an int-to-rune conversion. Keep a manual admin-panel comment when no description label is set. The image-derived description (#127) overwrote any comment once the label was absent, which broke the e2e check that a console comment survives a tag reconcile. It is now a fallback: it is used on creation, fills an empty comment, and refreshes a comment that names another version of the same image, but never replaces a hand-written one. A description label stays authoritative and an empty one still turns the fallback off. Derive a single port-80 redirect per container and service name, so one container redirecting on several HTTPS ports of a service does not conflict with itself. Claude-Session: https://claude.ai/code/session_01JyHejLZBcAeHAAVJY6aqBo
Every service-protocol https endpoint (not itself on port 80) now gets the port-80 redirect without a label; docktail.service.http-redirect=false (or the indexed variant) opts out. An explicit true is still validated. The redirect never causes a conflict: a service name whose port 80 is declared by any container, or which is ignored, keeps that endpoint and the redirect is skipped with one info log. Several HTTPS ports or containers on one name share a single redirect aimed at 443, else the lowest port. With API credentials DockTail appends tcp:80 to an existing Service definition that does not allow it (ports are never removed). Without credentials, and on tailscaled older than 1.92 or without MagicDNS, it logs one warning per process instead of one per reconcile; HTTPS is unaffected. The e2e suite covers a real http:// request answered with 308 and the path and query kept, the opt-out, a port 80 taken by another container, tcp:80 being added to a definition that lacks it, and cleanup when the redirect is turned off and the container removed. Port assertions ignore redirect-only ports so existing HTTPS fixtures keep their checks. Claude-Session: https://claude.ai/code/session_01JyHejLZBcAeHAAVJY6aqBo
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.
Redirects
http://to HTTPS for https services by default: DockTail adds a port 80 handler with Tailscale's serveRedirectfield, pointing to the full MagicDNS name (avoids the${HOST}short-name cert mismatch, tailscale#21683). Opt out per service withdocktail.service.http-redirect=false(ordocktail.service.N.http-redirect=false).set-config, tailscale#18381)tcp:80to new and existing Service definitions itself (never removes ports)tcp:80in the admin console is optional, only if you want the redirectRelated: #37