From 747fdae26925d5e9b89dffca65ca77cdbf46d71c Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Fri, 7 Aug 2020 14:08:57 +1200 Subject: [PATCH] fix(agent/console): fix an issue with the agent console on Docker environments (#4169) --- api/http/handler/websocket/proxy.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/http/handler/websocket/proxy.go b/api/http/handler/websocket/proxy.go index 9ec317d9b..984240256 100644 --- a/api/http/handler/websocket/proxy.go +++ b/api/http/handler/websocket/proxy.go @@ -33,9 +33,12 @@ func (handler *Handler) proxyEdgeAgentWebsocketRequest(w http.ResponseWriter, r } func (handler *Handler) proxyAgentWebsocketRequest(w http.ResponseWriter, r *http.Request, params *webSocketRequestParams) error { - // TODO: k8s merge - make sure this is still working with Docker agent - //agentURL, err := url.Parse(params.endpoint.URL) - agentURL, err := url.Parse(fmt.Sprintf("http://%s", params.endpoint.URL)) + endpointURL := params.endpoint.URL + if params.endpoint.Type == portainer.AgentOnKubernetesEnvironment { + endpointURL = fmt.Sprintf("http://%s", params.endpoint.URL) + } + + agentURL, err := url.Parse(endpointURL) if err != nil { return err }