reverseproxy: Support header selection policy on Host field (#3653)

This commit is contained in:
Francis Lavoie 2020-08-17 17:14:46 -04:00 committed by GitHub
parent e385be9225
commit fc65320e9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -362,6 +362,13 @@ func (s HeaderHashSelection) Select(pool UpstreamPool, req *http.Request) *Upstr
if s.Field == "" { if s.Field == "" {
return nil return nil
} }
// The Host header should be obtained from the req.Host field
// since net/http removes it from the header map.
if s.Field == "Host" && req.Host != "" {
return hostByHashing(pool, req.Host)
}
val := req.Header.Get(s.Field) val := req.Header.Get(s.Field)
if val == "" { if val == "" {
return RandomSelection{}.Select(pool, req) return RandomSelection{}.Select(pool, req)