mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 10:13:39 +08:00
reverseproxy: Support header selection policy on Host
field (#3653)
This commit is contained in:
parent
e385be9225
commit
fc65320e9c
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user