From fea0e3dd92f2b473c3af24890b103805c3e33745 Mon Sep 17 00:00:00 2001 From: Kevin Weis Date: Fri, 4 Oct 2024 14:58:16 +0200 Subject: [PATCH] fix http host header Override the HTTP request header `Host` to the original target host, after resolving it's IP and creating the HTTP request context. --- prober/http.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prober/http.go b/prober/http.go index d79e8e1c..e23e23ff 100644 --- a/prober/http.go +++ b/prober/http.go @@ -392,7 +392,6 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr httpConfig.Method = "GET" } - origHost := targetURL.Host if ip != nil { // Replace the host field in the URL with the IP we resolved. if targetPort == "" { @@ -430,7 +429,7 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr level.Error(logger).Log("msg", "Error creating request", "err", err) return } - request.Host = origHost + request.Host = targetHost request = request.WithContext(ctx) for key, value := range httpConfig.Headers {