mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 06:34:40 +03:00
add reverse proxying websocket connections
if we recognize that a request for a WebForward is trying to turn the connection into a websocket, we forward it to the backend and check if the backend understands the websocket request. if so, we pass back the upgrade response and get out of the way, copying bytes between the two. we do log the total amount of bytes read from the client and written to the client. if the backend doesn't respond with a websocke response, or an invalid one, we respond with a regular non-websocket response. and we log details about the failed connection, should help with debugging and any bug reports. we don't try to parse the websocket framing, that's between the client and the backend. we could try to parse it, in part to protect the backend from bad frames, but it would be a lot of work and could be brittle in the face of extensions. this doesn't yet handle websocket connections when a http proxy is configured. we'll implement it when someone needs it. we do recognize it and fail the connection. for issue #25
This commit is contained in:
@ -715,6 +715,11 @@ describe-static" and "mox config describe-domains":
|
||||
# unmodified. New X-Forwarded-{For,Host,Proto} headers are set. Any query string
|
||||
# in the URL is ignored. Requests are made using Go's net/http.DefaultTransport
|
||||
# that takes environment variables HTTP_PROXY and HTTPS_PROXY into account.
|
||||
# Websocket connections are forwarded and data is copied between client and
|
||||
# backend without looking at the framing. The websocket 'version' and
|
||||
# 'key'/'accept' headers are verified during the handshake, but other websocket
|
||||
# headers, including 'origin', 'protocol' and 'extensions' headers, are not
|
||||
# inspected and the backend is responsible for verifying/interpreting them.
|
||||
URL:
|
||||
|
||||
# Headers to add to the response. Useful for adding security- and cache-related
|
||||
|
Reference in New Issue
Block a user