mirror of https://github.com/status-im/consul.git
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:
parent
9168da8bb3
commit
a0455774c0
|
@ -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.
|
||||||
|
```
|
|
@ -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())
|
||||||
|
|
Loading…
Reference in New Issue