mirror of
https://github.com/traefik/traefik
synced 2026-02-03 11:10:33 +00:00
Scope the rate limit counter key by source AND by middleware
This commit is contained in:
@@ -146,7 +146,12 @@ func (rl *rateLimiter) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
logger.Info().Msgf("ignoring token bucket amount > 1: %d", amount)
|
||||
}
|
||||
|
||||
delay, err := rl.limiter.Allow(ctx, source)
|
||||
// Each rate limiter has its own source space,
|
||||
// ensuring independence between rate limiters,
|
||||
// i.e., rate limit rules are only applied based on traffic
|
||||
// where the rate limiter is active.
|
||||
rlSource := fmt.Sprintf("%s:%s", rl.name, source)
|
||||
delay, err := rl.limiter.Allow(ctx, rlSource)
|
||||
if err != nil {
|
||||
rl.logger.Error().Err(err).Msg("Could not insert/update bucket")
|
||||
observability.SetStatusErrorf(ctx, "Could not insert/update bucket")
|
||||
|
||||
Reference in New Issue
Block a user