diff --git a/pkg/logagent/registry/logagent/storage/proxy.go b/pkg/logagent/registry/logagent/storage/proxy.go index 94a60a93de..3046c7af81 100644 --- a/pkg/logagent/registry/logagent/storage/proxy.go +++ b/pkg/logagent/registry/logagent/storage/proxy.go @@ -72,6 +72,7 @@ func (r *LogagentProxyREST) Connect(ctx context.Context, clusterName string, opt if err != nil { return nil, err } + log.Errorf("location: %+v\n", location) return &logAgentProxyHandler{ location: location, transport: transport, @@ -117,7 +118,9 @@ func (h *logAgentProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques if h.token != "" { newReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", strings.TrimSpace(h.token))) } + log.Errorf("req is: %+v\n", newReq) + log.Errorf("targety is: %+v\n", &url.URL{Scheme: h.location.Scheme, Host: h.location.Host}) reverseProxy := httputil.NewSingleHostReverseProxy(&url.URL{Scheme: h.location.Scheme, Host: h.location.Host}) reverseProxy.Transport = h.transport reverseProxy.FlushInterval = 100 * time.Millisecond diff --git a/pkg/logagent/util/cluster.go b/pkg/logagent/util/cluster.go index 3b4e32472a..afdf0f978a 100644 --- a/pkg/logagent/util/cluster.go +++ b/pkg/logagent/util/cluster.go @@ -94,11 +94,12 @@ func APIServerLocationByCluster(ctx context.Context, clusterName string, platfor if credential.Token != nil { token = *credential.Token } - return &url.URL{ - Scheme: "https", - Host: restConfig.Host, - Path: requestInfo.Path, - }, transport, token, nil + apiserver, err := url.Parse(restConfig.Host) + if err != nil { + return nil, nil, "", err + } + apiserver.Path = requestInfo.Path + return apiserver, transport, token, nil } //use cache to optimize this function