Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #17142 #17145

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api4/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/gobwas/ws"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/shared/mlog"
)

func (api *API) InitWebSocket() {
Expand All @@ -29,6 +30,14 @@ func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) {
Timeout: 5 * time.Second,
}

// Uprgade the HTTP version header to 1.1, if we detect a 1.0 header.
// This is a hack to work around a flaw in our proxy configs which sends the protocol version as 1.0.
// It will be removed in a future version.
if r.ProtoMajor == 1 && r.ProtoMinor == 0 {
r.ProtoMinor = 1
mlog.Warn("The HTTP version field was detected as 1.0 during WebSocket handshake. This is most probably due to an incorrect proxy configuration. Please upgrade your proxy config to set the header version to a minimum of 1.1.")
}

conn, _, _, err := upgrader.Upgrade(r, w)
if err != nil {
c.Err = model.NewAppError("connect", "api.web_socket.connect.upgrade.app_error", nil, "", http.StatusInternalServerError)
Expand Down