Skip to content

Commit

Permalink
reverseproxy: Support header selection policy on Host field (#3653)
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Aug 17, 2020
1 parent e385be9 commit fc65320
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/caddyhttp/reverseproxy/selectionpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fc65320

Please sign in to comment.