mholt/caddy-ratelimit

Multiple routes issue

maracko opened this issue · 1 comments

I have the following .Caddyfile :


{
  order rate_limit before basicauth
  admin off
}

(rate_limit_num_per_min) {
  rate_limit {
      zone register_limit {
      key    {http.request.remote.host}
      events {args.0}
      window {args.1}s
      }  
  }
}



localhost {

  encode zstd gzip
  reverse_proxy /*  https://www.example.com

  route  /user/login {
    import rate_limit_num_per_min 5 10
  }

  route  /user/register {
   import rate_limit_num_per_min 1 10
  }

}

However on both limited routes the same rate limit is applied (5 requests per 10 minutes) and both routes share the cooldown, which is not the desired outcome.

This is maybe the supposed to work like that (not very experienced with Caddy)?

If there is a better way to do this or even group the rate limit to cover multiple routes with same parameters but not share the limit I would appreciate help.

mholt commented

That's because both those routes use the same zone. Give the zone a different name to use different state.