summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/reverseproxy/selectionpolicies.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go
index e33ebe4..343140f 100644
--- a/modules/caddyhttp/reverseproxy/selectionpolicies.go
+++ b/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)