Browse Source
reverseproxy: Support header selection policy on `Host` field (#3653)
master
Francis Lavoie
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
0 deletions
-
modules/caddyhttp/reverseproxy/selectionpolicies.go
|
|
@ -362,6 +362,13 @@ func (s HeaderHashSelection) Select(pool UpstreamPool, req *http.Request) *Upstr |
|
|
|
if s.Field == "" { |
|
|
|
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) |
|
|
|
if val == "" { |
|
|
|
return RandomSelection{}.Select(pool, req) |
|
|
|