Skip to content

Commit

Permalink
Set Host field appropriately when passing through probes (#20371)
Browse files Browse the repository at this point in the history
* Set Host field appropriately when passing through probes

If someone sets a Host header, we shouldn't overwrite it back to
localhost. The health check might be affected by the value of that
header. We should ensure the host field is set to the provided host
header, if set on the probe

* cover :authority too
  • Loading branch information
jackkleeman authored and istio-testing committed Jan 21, 2020
1 parent 18965ce commit 517b14c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pilot/cmd/pilot-agent/status/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ func (s *Server) handleAppProbe(w http.ResponseWriter, req *http.Request) {
appReq.Header[name] = newValues
}

for _, h := range prober.HTTPHeaders {
if h.Name == "Host" || h.Name == ":authority" {
// Probe has specific host header override; honor it
appReq.Host = h.Value
break
}
}

// Send the request.
response, err := httpClient.Do(appReq)
if err != nil {
Expand Down

0 comments on commit 517b14c

Please sign in to comment.