When a host header is defined override `req.Host` in the metrics ui (#13071)

* When a host header is defined override the req.Host in the metrics ui endpoint.

* add changelog
This commit is contained in:
Dhia Ayachi 2022-05-13 14:05:22 -04:00 committed by GitHub
parent d33d06e033
commit 70b93ea693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

3
.changelog/13071.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
Fix a bug when configuring an `add_headers` directive named `Host` the header is not set for `v1/internal/ui/metrics-proxy/` endpoint.
```

View File

@ -740,7 +740,11 @@ func (s *HTTPHandlers) UIMetricsProxy(resp http.ResponseWriter, req *http.Reques
// Add any configured headers // Add any configured headers
for _, h := range cfg.AddHeaders { for _, h := range cfg.AddHeaders {
req.Header.Set(h.Name, h.Value) if strings.ToLower(h.Name) == "host" {
req.Host = h.Value
} else {
req.Header.Set(h.Name, h.Value)
}
} }
log.Debug("proxying request", "to", u.String()) log.Debug("proxying request", "to", u.String())