Skip to content

Commit

Permalink
fix http host header
Browse files Browse the repository at this point in the history
Override the HTTP request header `Host` to the original target host, after resolving it's IP and creating the HTTP request context.
  • Loading branch information
compilenix committed Oct 4, 2024
1 parent 0e4b727 commit fea0e3d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions prober/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit fea0e3d

Please sign in to comment.