Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #421: Close websocket connection on failure
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
a2ba01f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates the RFC, and looking at our Websocket engine, will definitely not work.
5. The request MUST contain an |Upgrade| header field whose value MUST include the "websocket" keyword.
6. The request MUST contain a |Connection| header field whose value MUST include the "Upgrade" token.
https://tools.ietf.org/html/rfc6455 Page 16/17
You might get away with r.Header.Add("Connection", "close") but ultimately I think you should be interpreting the HTTP response to the upgrade request, to know if you should keep the raw proxy in place or close.
Any status code other than 101 indicates that the WebSocket handshake has not completed and that the semantics of HTTP still apply.
https://tools.ietf.org/html/rfc6455 Page 7