Skip to content

Commit 328fb61

Browse files
authored
reverseproxy: Only handle websocket protocol (#6740)
1 parent bcaa8aa commit 328fb61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/caddyhttp/reverseproxy/reverseproxy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
398398
}
399399
// websocket over http2, assuming backend doesn't support this, the request will be modified to http1.1 upgrade
400400
// TODO: once we can reliably detect backend support this, it can be removed for those backends
401-
if r.ProtoMajor == 2 && r.Method == http.MethodConnect && r.Header.Get(":protocol") != "" {
401+
if r.ProtoMajor == 2 && r.Method == http.MethodConnect && r.Header.Get(":protocol") == "websocket" {
402402
clonedReq.Header.Del(":protocol")
403403
// keep the body for later use. http1.1 upgrade uses http.NoBody
404404
caddyhttp.SetVar(clonedReq.Context(), "h2_websocket_body", clonedReq.Body)
405405
clonedReq.Body = http.NoBody
406406
clonedReq.Method = http.MethodGet
407-
clonedReq.Header.Set("Upgrade", r.Header.Get(":protocol"))
407+
clonedReq.Header.Set("Upgrade", "websocket")
408408
clonedReq.Header.Set("Connection", "Upgrade")
409409
key := make([]byte, 16)
410410
_, randErr := rand.Read(key)

0 commit comments

Comments
 (0)