varnish / varnish-modules

Collection of Varnish Cache modules (vmods) by Varnish Software
Other
182 stars 86 forks source link

vsthrottle.blocked doesn't report block time when specified #149

Closed anthosz closed 4 years ago

anthosz commented 4 years ago

Hello,

My issue concern vsthrottle.blocked. Indeed, each time that I am blocked, I receive a "Retry-After: 5 " instead to receive a "Retry-After: 20".

Here are an example of my config:

vcl_pass {
      if (vsthrottle.is_denied("test"+req.http.User-Agent, 10, 10s, 20s)) {
        return (synth(429, "Too Many Requests"));
      }
}
vcl_deliver {
  set resp.http.X-RateLimit-Remaining = vsthrottle.remaining("test"+req.http.User-Agent, 10, 10s, 20s);
  set resp.http.Retry-After = vsthrottle.blocked("test"+req.http.User-Agent, 10, 10s, 20s);
}

Concerning vsthrottle.is_denied & vsthrottle.remaining, no problem, it works.

I use Varnish 6.3.1 with 6.3 branch from this repository.

Best regards,

gquintard commented 4 years ago

note that if you return synth(), you'll end up in vcl_synth, not in vcl_deliver. Could that be the source of the confusion?

anthosz commented 4 years ago

Hi @gquintard ,

Indeed, thx!