From 606639fa43618afc16ac54901e27de09b0ed98fe Mon Sep 17 00:00:00 2001 From: Erik Pellizzon Date: Fri, 27 Dec 2024 13:12:43 +0100 Subject: [PATCH] Fix host if we already had the port --- websocket.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/websocket.go b/websocket.go index c394b7a7..64bc7405 100644 --- a/websocket.go +++ b/websocket.go @@ -38,6 +38,9 @@ func (proxy *ProxyHttpServer) serveWebsocketTLS( host, port, err := net.SplitHostPort(req.URL.Host) if err != nil || port == "" { host = net.JoinHostPort(req.URL.Host, "443") + } else { + // We already had a port, just use it + host = req.URL.Host } targetURL := url.URL{Scheme: "wss", Host: host, Path: req.URL.Path} @@ -70,6 +73,9 @@ func (proxy *ProxyHttpServer) serveWebsocketHttpOverTLS( host, port, err := net.SplitHostPort(req.URL.Host) if err != nil || port == "" { host = net.JoinHostPort(req.URL.Host, "80") + } else { + // We already had a port, just use it + host = req.URL.Host } targetURL := url.URL{Scheme: "ws", Host: host, Path: req.URL.Path}