Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverseproxy: Support header selection policy on `Host` field (#3653)
Francis Lavoie committed
Aug 17, 2020 at 17:14 UTC
fc65320e9c5b4e2ab96b6b421b65629560f1b8a2
1 file changed
+7
modules/caddyhttp/reverseproxy/selectionpolicies.go
+7
@@ -362,6 +362,13 @@ func (s HeaderHashSelection) Select(pool UpstreamPool, req *http.Request) *Upstr
362
if s.Field == "" {
363
return nil
364
}
365
+
366
+ // The Host header should be obtained from the req.Host field
367
+ // since net/http removes it from the header map.
368
+ if s.Field == "Host" && req.Host != "" {
369
+ return hostByHashing(pool, req.Host)
370
+ }
371
+
372
val := req.Header.Get(s.Field)
373
if val == "" {
374
return RandomSelection{}.Select(pool, req)