Custom counter module(vmod_xcounter)

kokoniimasu kokoniimasu at gmail.com
Fri Nov 30 08:12:56 UTC 2018


Hi, All.

I created a vmod_xcounter that can easily add counters.
I think it can use in various situations.

I'm using vsthrottle together.

- vcl

  vcl 4.0;
  import xcounter;
  import vsthrottle;

  sub vcl_init {
    new atk_login   = xcounter.vsc(hidevclname=1, groupname="attack.");
    ...
  }

  sub vcl_recv {
  ...
    if(req.method == "POST" &&  req.url ~ ****){
      if(vsthrottle.is_denied("LOGIN:" + req.http.****, **, 60s)) {
        atk_login.incr(1);
        return (synth(429, "Too Many Requests"));
      }
  ...
    }
  ...
  }

- output
  https://raw.githubusercontent.com/xcir/libvmod-xcounter/master/res/varnishstat.png


https://github.com/xcir/libvmod-xcounter

I hope that this vmod is of help to you.

--
Shohei Tanaka(@xcir)
http://blog.xcir.net/ (JP)


More information about the varnish-misc mailing list