Fix https scheme for Coder-fronted apps (X-Forwarded-Proto middleware)#174
Merged
Conversation
Coder terminates TLS and forwards to DDEV's Traefik over plain-HTTP
entrypoints (tls: false), so Traefik handed backends
X-Forwarded-Proto: http. Apps then generated http:// URLs and browsers
broke on the https->http downgrade (e.g. TYPO3 MissingReferrerException
on /typo3/, where the browser drops the Referer header).
coder-routes now defines a Traefik headers middleware
({project}-coder-https) forcing X-Forwarded-Proto: https
(plus X-Forwarded-Ssl: on, X-Forwarded-Port: 443) and attaches it to
every generated router, restoring the real external scheme. This is
generic across all Coder-fronted services (web backend, mailpit, xhgui,
port-forward dev servers).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Problem
Coder terminates TLS at
https://*.coder.ddev.comand reverse-proxies to DDEV's Traefik over plain-HTTP entrypoints (the generated Coder routers usetls: false). As a result Traefik hands the backendX-Forwarded-Proto: http, and DDEV's nginx — which derivesHTTPSsolely from that header (map $http_x_forwarded_proto $fcgi_https) — reportsHTTPS=offto PHP.Apps then generate
http://absolute URLs while the browser is on anhttps://page. The most visible casualty is the TYPO3 backend:/typo3/throwsbecause its
referrer-refreshredirect is stampedhttp://, and the browser drops theRefererheader on thehttps://→http://downgrade. Frontend rendering, canonical tags, sitemaps, and generated emails are affected by the same scheme misdetection.Fix
coder-routesnow defines a Traefikheadersmiddleware ({project}-coder-https) and attaches it to every generated router. Since HTTPS always terminates at the Coder proxy, it forces the real external scheme:This is generic across all Coder-fronted services (web backend, mailpit, xhgui, and dynamic port-forward dev servers such as Vite/Astro).
Verification
Probed through the exact
http-8080entrypoint the Coder proxy uses, with no client-supplied forwarded header:HTTPSseen by PHPoffonX-Forwarded-ProtohttpsTYPO3 now detects HTTPS, renders
https://backend URLs, and/typo3/loads withoutMissingReferrerException.Changes
image/scripts/.ddev/commands/host/coder-routes— define + attach the middlewaredocs/reference/coder-url-patterns.md— document the scheme-correction behavior🤖 Generated with Claude Code