From 12e7aa6b60f8f9d1ee195e16508e5e0d6cf83938 Mon Sep 17 00:00:00 2001 From: Marcelo Rydel Date: Thu, 14 Oct 2021 09:40:14 -0300 Subject: [PATCH] fix(environments): don't override with local IP [EE-1561] (#5785) fix(environments): don't override with local IP [EE-1561] (#5785) --- api/http/proxy/factory/docker.go | 5 +++-- api/http/proxy/factory/kubernetes.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/http/proxy/factory/docker.go b/api/http/proxy/factory/docker.go index 513b5731d..c771cb0c2 100644 --- a/api/http/proxy/factory/docker.go +++ b/api/http/proxy/factory/docker.go @@ -32,12 +32,13 @@ func (factory *ProxyFactory) newDockerLocalProxy(endpoint *portainer.Endpoint) ( } func (factory *ProxyFactory) newDockerHTTPProxy(endpoint *portainer.Endpoint) (http.Handler, error) { + rawURL := endpoint.URL if endpoint.Type == portainer.EdgeAgentOnDockerEnvironment { tunnel := factory.reverseTunnelService.GetTunnelDetails(endpoint.ID) - endpoint.URL = fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port) + rawURL = fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port) } - endpointURL, err := url.Parse(endpoint.URL) + endpointURL, err := url.Parse(rawURL) if err != nil { return nil, err } diff --git a/api/http/proxy/factory/kubernetes.go b/api/http/proxy/factory/kubernetes.go index 1d96d3fd5..2b04b795b 100644 --- a/api/http/proxy/factory/kubernetes.go +++ b/api/http/proxy/factory/kubernetes.go @@ -52,9 +52,9 @@ func (factory *ProxyFactory) newKubernetesLocalProxy(endpoint *portainer.Endpoin func (factory *ProxyFactory) newKubernetesEdgeHTTPProxy(endpoint *portainer.Endpoint) (http.Handler, error) { tunnel := factory.reverseTunnelService.GetTunnelDetails(endpoint.ID) - endpoint.URL = fmt.Sprintf("http://localhost:%d", tunnel.Port) + rawURL := fmt.Sprintf("http://localhost:%d", tunnel.Port) - endpointURL, err := url.Parse(endpoint.URL) + endpointURL, err := url.Parse(rawURL) if err != nil { return nil, err }