diff options
author | bt90 <[email protected]> | 2024-12-11 19:17:05 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-11 11:17:05 -0700 |
commit | 328fb614f0e9996b184f41d59b7092c21dd9c712 (patch) | |
tree | c3f025b57a34aecb55c9a345b18f4ac6af305985 /modules/caddyhttp/reverseproxy/reverseproxy.go | |
parent | bcaa8aaf114629031d10dcef0ca7680ae8163e32 (diff) | |
download | caddy-328fb614f0e9996b184f41d59b7092c21dd9c712.tar.gz caddy-328fb614f0e9996b184f41d59b7092c21dd9c712.zip |
reverseproxy: Only handle websocket protocol (#6740)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/reverseproxy.go')
-rw-r--r-- | modules/caddyhttp/reverseproxy/reverseproxy.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go index 46f1fe5bb..64804e18b 100644 --- a/modules/caddyhttp/reverseproxy/reverseproxy.go +++ b/modules/caddyhttp/reverseproxy/reverseproxy.go @@ -398,13 +398,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht } // websocket over http2, assuming backend doesn't support this, the request will be modified to http1.1 upgrade // TODO: once we can reliably detect backend support this, it can be removed for those backends - if r.ProtoMajor == 2 && r.Method == http.MethodConnect && r.Header.Get(":protocol") != "" { + if r.ProtoMajor == 2 && r.Method == http.MethodConnect && r.Header.Get(":protocol") == "websocket" { clonedReq.Header.Del(":protocol") // keep the body for later use. http1.1 upgrade uses http.NoBody caddyhttp.SetVar(clonedReq.Context(), "h2_websocket_body", clonedReq.Body) clonedReq.Body = http.NoBody clonedReq.Method = http.MethodGet - clonedReq.Header.Set("Upgrade", r.Header.Get(":protocol")) + clonedReq.Header.Set("Upgrade", "websocket") clonedReq.Header.Set("Connection", "Upgrade") key := make([]byte, 16) _, randErr := rand.Read(key) |