diff --git a/internal/proxy/transport.go b/internal/proxy/transport.go index 9bb4b01..73dd3ac 100644 --- a/internal/proxy/transport.go +++ b/internal/proxy/transport.go @@ -17,6 +17,8 @@ package proxy import ( "fmt" "net/http" + "net/url" + "strings" "time" httpkit "github.com/soulteary/http-kit" @@ -57,6 +59,21 @@ func NewRetryableTransport(baseTransport http.RoundTripper) *RetryableTransport func (rt *RetryableTransport) RoundTrip(req *http.Request) (*http.Response, error) { ctx := req.Context() + // Add http:// + if req.URL.Scheme == "" { + httpURL, err := url.Parse("http://" + strings.Replace(req.URL.Path, "/", "", 1)) + if err != nil { + return nil, err + } + httpReq, err := http.NewRequestWithContext(ctx, req.Method, httpURL.String(), nil) + if err != nil { + return nil, err + } + httpReq.Header = req.Header.Clone() + httpReq.Header.Set("Host", httpReq.Host) + req = httpReq + } + // Start tracing span spanCtx, span := tracing.StartSpan(ctx, "proxy.upstream.request") defer span.End()