From 4438c8ff91449881c3f621446fe62f2f2e0186a4 Mon Sep 17 00:00:00 2001 From: Simao Gomes Viana Date: Thu, 29 Apr 2021 09:58:28 +0200 Subject: [PATCH] caddyhttp: reverseproxy: fix hash selection policy Fixes: #4135 Test: go test './...' -count=1 --- modules/caddyhttp/reverseproxy/selectionpolicies.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go index 357ee33a90b1..001f7f8065e1 100644 --- a/modules/caddyhttp/reverseproxy/selectionpolicies.go +++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go @@ -523,8 +523,7 @@ func hostByHashing(pool []*Upstream, s string) *Upstream { } index := hash(s) % poolLen for i := uint32(0); i < poolLen; i++ { - index += i - upstream := pool[index%poolLen] + upstream := pool[(index+i)%poolLen] if upstream.Available() { return upstream }