diff --git a/api/chisel/service.go b/api/chisel/service.go index bb2d3357d..efb08db71 100644 --- a/api/chisel/service.go +++ b/api/chisel/service.go @@ -179,7 +179,7 @@ func (service *Service) snapshotEnvironment(endpointID portainer.EndpointID, tun } endpointURL := endpoint.URL - endpoint.URL = fmt.Sprintf("tcp://localhost:%d", tunnelPort) + endpoint.URL = fmt.Sprintf("tcp://127.0.0.1:%d", tunnelPort) snapshot, err := service.snapshotter.CreateSnapshot(endpoint) if err != nil { return err diff --git a/api/docker/client.go b/api/docker/client.go index e063ad984..c1bd7a8d0 100644 --- a/api/docker/client.go +++ b/api/docker/client.go @@ -81,7 +81,7 @@ func createEdgeClient(endpoint *portainer.Endpoint, reverseTunnelService portain } tunnel := reverseTunnelService.GetTunnelDetails(endpoint.ID) - endpointURL := fmt.Sprintf("http://localhost:%d", tunnel.Port) + endpointURL := fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port) return client.NewClientWithOpts( client.WithHost(endpointURL), diff --git a/api/exec/swarm_stack.go b/api/exec/swarm_stack.go index e50eacb63..d5b779a02 100644 --- a/api/exec/swarm_stack.go +++ b/api/exec/swarm_stack.go @@ -123,7 +123,7 @@ func (manager *SwarmStackManager) prepareDockerCommandAndArgs(binaryPath, dataPa endpointURL := endpoint.URL if endpoint.Type == portainer.EdgeAgentEnvironment { tunnel := manager.reverseTunnelService.GetTunnelDetails(endpoint.ID) - endpointURL = fmt.Sprintf("tcp://localhost:%d", tunnel.Port) + endpointURL = fmt.Sprintf("tcp://127.0.0.1:%d", tunnel.Port) } args = append(args, "-H", endpointURL) diff --git a/api/http/handler/websocket/proxy.go b/api/http/handler/websocket/proxy.go index 4acb7a620..bd8e3f4f7 100644 --- a/api/http/handler/websocket/proxy.go +++ b/api/http/handler/websocket/proxy.go @@ -14,7 +14,7 @@ import ( func (handler *Handler) proxyEdgeAgentWebsocketRequest(w http.ResponseWriter, r *http.Request, params *webSocketRequestParams) error { tunnel := handler.ReverseTunnelService.GetTunnelDetails(params.endpoint.ID) - endpointURL, err := url.Parse(fmt.Sprintf("http://localhost:%d", tunnel.Port)) + endpointURL, err := url.Parse(fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port)) if err != nil { return err } diff --git a/api/http/proxy/factory/docker.go b/api/http/proxy/factory/docker.go index 365abb2fb..acf0731bd 100644 --- a/api/http/proxy/factory/docker.go +++ b/api/http/proxy/factory/docker.go @@ -34,7 +34,7 @@ func (factory *ProxyFactory) newDockerLocalProxy(endpoint *portainer.Endpoint) ( func (factory *ProxyFactory) newDockerHTTPProxy(endpoint *portainer.Endpoint) (http.Handler, error) { if endpoint.Type == portainer.EdgeAgentEnvironment { tunnel := factory.reverseTunnelService.GetTunnelDetails(endpoint.ID) - endpoint.URL = fmt.Sprintf("http://localhost:%d", tunnel.Port) + endpoint.URL = fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port) } endpointURL, err := url.Parse(endpoint.URL) diff --git a/api/libcompose/compose_stack.go b/api/libcompose/compose_stack.go index 30322d7d8..d3bf546c3 100644 --- a/api/libcompose/compose_stack.go +++ b/api/libcompose/compose_stack.go @@ -39,7 +39,7 @@ func (manager *ComposeStackManager) createClient(endpoint *portainer.Endpoint) ( endpointURL := endpoint.URL if endpoint.Type == portainer.EdgeAgentEnvironment { tunnel := manager.reverseTunnelService.GetTunnelDetails(endpoint.ID) - endpointURL = fmt.Sprintf("tcp://localhost:%d", tunnel.Port) + endpointURL = fmt.Sprintf("tcp://127.0.0.1:%d", tunnel.Port) } clientOpts := client.Options{ diff --git a/api/portainer.go b/api/portainer.go index acf16961b..5e69a2eb5 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -953,7 +953,7 @@ const ( // to be used when communicating with an agent PortainerAgentSignatureMessage = "Portainer-App" // ExtensionServer represents the server used by Portainer to communicate with extensions - ExtensionServer = "localhost" + ExtensionServer = "127.0.0.1" // DefaultEdgeAgentCheckinIntervalInSeconds represents the default interval (in seconds) used by Edge agents to checkin with the Portainer instance DefaultEdgeAgentCheckinIntervalInSeconds = 5 // LocalExtensionManifestFile represents the name of the local manifest file for extensions