Skip to content

Commit

Permalink
Issue #421: Close websocket connection on failure
Browse files Browse the repository at this point in the history
The websocket proxy is implemented as a raw tcp proxy
which relies on the client and server to close the
connection. When a websocket upgrade fails the upstream
server may keep the connection open.

If a proxy like nginx is used in front of fabio
it will keep its connection to fabio open effectively
establishing a direct channel between nginx and the
upstream server which will be used for any request
forwarded by nginx to fabio.

Adding a 'Connection: close' header to the upstream
request should indicate to the server to close the
connection. If that works then we can keep the raw
tcp proxy for websockets. Otherwise, fabio needs
to handle the handshake and close the connection
itself.

Fixes #421
  • Loading branch information
magiconair committed Mar 22, 2018
1 parent e056f14 commit 9e26812
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions proxy/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (p *HTTPProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} else {
h = newRawProxy(targetURL.Host, net.Dial)
}
r.Header.Set("Connection", "close")

case accept == "text/event-stream":
// use the flush interval for SSE (server-sent events)
Expand Down

0 comments on commit 9e26812

Please sign in to comment.