Mailing List Archive

Custom counter module(vmod_xcounter)
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)
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Custom counter module(vmod_xcounter) [ In reply to ]
Nice!

--
Guillaume Quintard


On Fri, Nov 30, 2018 at 12:14 AM kokoniimasu <kokoniimasu@gmail.com> wrote:

> 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)
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: Custom counter module(vmod_xcounter) [ In reply to ]
Thanks!
2018?12?1?(?) 3:12 Guillaume Quintard <guillaume@varnish-software.com>:
>
> Nice!
>
> --
> Guillaume Quintard
>
>
> On Fri, Nov 30, 2018 at 12:14 AM kokoniimasu <kokoniimasu@gmail.com> wrote:
>>
>> 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)
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc@varnish-cache.org
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc