Repository navigation
Accept ws and wss in X-Forwarded-Proto for the monitoring UI - #3418
Merged
jedisct1 merged 1 commit intoNov 12, 2026
Merged
Conversation
Some reverse proxies, such as Traefik, report WebSocket handshakes as ws or wss. These values were ignored, so behind a TLS-terminating proxy the scheme was assumed to be http: the origin check rejected the https origin of the dashboard, and accepted an http one. Map ws to http and wss to https.
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.
Since 2.1.19, the monitoring UI never gets its live connection behind a TLS-terminating reverse proxy that reports WebSocket handshakes as
X-Forwarded-Proto: wss(Traefik does): everyGET /api/wsis answered with 403, the log fills withWebSocket upgrade error: websocket: request origin not allowed by Upgrader.CheckOrigin, and the page falls back to polling. It can be reproduced without a proxy by sending the handshake to the UI withHost: dns.example,Origin: https://dns.exampleandX-Forwarded-Proto: wss.The origin check added in b00a0fc compares the scheme of
OriginwithrequestScheme(), which only knowshttpandhttps. Any other value falls through tor.TLS, so the request is taken for plain http and the https origin of the dashboard is refused, whileOrigin: http://dns.exampleis accepted on that same request.wsis now read ashttpandwssashttps. Nothing else changes: an origin is accepted exactly when it would be with the equivalenthttp/httpsvalue. Traefik sets these two values here.Tested with a new table test of the origin check (the ws/wss rows fail before the change;
go testandgo vetpass after), and with the built proxy and a raw handshake carrying the proxy headers:Not covered: the
Forwardedheader is still not read, and I did not put a real Traefik in front of it.Discussion #3389 reports this error behind Traefik.