From batanun at hotmail.com Mon Nov 15 14:08:28 2021 From: batanun at hotmail.com (Batanun B) Date: Mon, 15 Nov 2021 14:08:28 +0000 Subject: Keeping multiple cookies based on regex or prefix, with Varnish 6.0 Message-ID: Hi, We use Varnish Cache 6.0 LTS, with varnish modules 0.15.0. As far as I can see, this includes a version of the cookie vmod that doesn't support regex. Yet, our use case leans towards using a regex, or at least a substring. Case in point. Our frontend uses a bunch of cookies. And a handful of them is needed by the backend too. I have done a simple test case, with a just a single cookie, and was able to use the built in cookie vmod to allow that cookie to go through to the backend. But in order for this to be useful for us, we need to allow multiple cookies. Cookies that we don't know the exact name of when writing the VCL. But they will all start with a defined prefix. Example: The incoming request contains the following cookie header: Cookie: _fbp=fb.123; _gid=GA1.2.3; custom-x=qwerty; _ga_ABCD=GS1.123; custom-y=qwerty; _ga=GA1123 And we want to keep all cookies that start with "custom-", hence we want the rewritten cookie header to be: Cookie: custom-x=qwerty; custom-y=qwerty How can we achieve this with our version of Varnish and varnish-modules? -------------- next part -------------- An HTML attachment was scrubbed... URL: From joh.hendriks at gmail.com Tue Nov 16 22:41:50 2021 From: joh.hendriks at gmail.com (Johan Hendriks) Date: Tue, 16 Nov 2021 23:41:50 +0100 Subject: Keeping multiple cookies based on regex or prefix, with Varnish 6.0 In-Reply-To: References: Message-ID: <7d2e30d1-3ead-5c8a-eeed-21d61c35aeda@gmail.com> On 15/11/2021 15:08, Batanun B wrote: > Hi, > > We use Varnish Cache 6.0 LTS, with varnish modules?0.15.0. As far as I > can see, this includes a version of the cookie vmod that doesn't > support regex. Yet, our use case leans towards using a regex, or at > least a substring. > > Case in point. Our frontend uses a bunch of cookies. And a handful of > them is needed by the backend too. I have done a simple test case, > with a just a single cookie, and was able to use the built in cookie > vmod to allow that cookie to go through to the backend. But in order > for this to be useful for us, we need to allow multiple cookies. > Cookies that we don't know the exact name of when writing the VCL. But > they will all start with a defined prefix. > > Example: > The incoming request contains the following cookie header: > > *Cookie: _fbp=fb.123; _gid=GA1.2.3; custom-x=qwerty; _ga_ABCD=GS1.123; > custom-y=qwerty; _ga=GA1123* > > And we want to keep all cookies that start with "custom-", hence we > want the rewritten cookie header to be: > > *Cookie: custom-x=qwerty; custom-y=qwerty* > > How can we achieve this with our version of Varnish and varnish-modules? > > _______________________________________________ > varnish-misc mailing list > varnish-misc at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc Maybe you can use the cookie config from the drupal vcl example on https://www.varnish-software.com/developers/tutorials/configuring-varnish-drupal/ if (req.http.Cookie) { ??????? set req.http.Cookie = ";" + req.http.Cookie; ??????? set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); ??????? set req.http.Cookie = regsuball(req.http.Cookie, ";(S?custom-[a-z0-9]+)=", "; \1="); ??????? set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", ""); ??????? set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", ""); ??????? if (req.http.cookie ~ "^\s*$") { ??????????? unset req.http.cookie; ??????? } else { ??????????? return(pass); ??????? } } If my regex foo is not failing me it will keep all cookie's that start with custom- and what comes after the dash. For this there is no need to use the cookie module as this works with a plain varnish-cache install. regards Johan Hendriks -------------- next part -------------- An HTML attachment was scrubbed... URL: From kokoniimasu at gmail.com Mon Nov 22 05:20:00 2021 From: kokoniimasu at gmail.com (kokoniimasu) Date: Mon, 22 Nov 2021 14:20:00 +0900 Subject: A tool to package VMOD easily Message-ID: Hi, All. I've been struggling for a long time to deploy VMOD in my environment. So I created a tool to build a VMOD package easily. The Package is intended to be installed in its own environment, and supports deb and rpm. ``` xcir at build01:~/git/vmod-packager$ ./vmod-packager.sh -d focal -v 7.0.0 -e 0.19 varnish-modules ... ################################################## docker image: vmod-packager/focal:7.0.0-1 Dist: focal Varnish Version: 7.0.0 Varnish VRT: 140 VMOD name: varnish-modules VMOD Version: 140.0.19 Status: SUCCESS xcir at build01:~/git/vmod-packager$ ls pkgs/debs/varnish-modules/ varnish-modules_140.0.19~focal-1_amd64.build varnish-modules_140.0.19~focal-1_amd64.changes varnish-modules-dbgsym_140.0.19~focal-1_amd64.ddeb varnish-modules_140.0.19~focal-1_amd64.buildinfo varnish-modules_140.0.19~focal-1_amd64.deb ``` It's still under development, but I think it will work. https://github.com/xcir/vmod-packager Regards, -- Shohei Tanaka(@xcir) https://blog.xcir.net/ (JP) -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaume.quintard at gmail.com Mon Nov 22 06:05:52 2021 From: guillaume.quintard at gmail.com (Guillaume Quintard) Date: Sun, 21 Nov 2021 22:05:52 -0800 Subject: A tool to package VMOD easily In-Reply-To: References: Message-ID: Sweet! I've been meaning to build something like that for a long time, that's great! On Sun, Nov 21, 2021, 21:22 kokoniimasu wrote: > Hi, All. > > I've been struggling for a long time to deploy VMOD in my environment. > So I created a tool to build a VMOD package easily. > The Package is intended to be installed in its own environment, and > supports deb and rpm. > > > ``` > xcir at build01:~/git/vmod-packager$ ./vmod-packager.sh -d focal -v 7.0.0 -e > 0.19 varnish-modules > ... > ################################################## > docker image: vmod-packager/focal:7.0.0-1 > Dist: focal > Varnish Version: 7.0.0 > Varnish VRT: 140 > VMOD name: varnish-modules > VMOD Version: 140.0.19 > Status: SUCCESS > > xcir at build01:~/git/vmod-packager$ ls pkgs/debs/varnish-modules/ > varnish-modules_140.0.19~focal-1_amd64.build > varnish-modules_140.0.19~focal-1_amd64.changes > varnish-modules-dbgsym_140.0.19~focal-1_amd64.ddeb > varnish-modules_140.0.19~focal-1_amd64.buildinfo > varnish-modules_140.0.19~focal-1_amd64.deb > ``` > > It's still under development, but I think it will work. > > https://github.com/xcir/vmod-packager > > Regards, > > -- > Shohei Tanaka(@xcir) > https://blog.xcir.net/ (JP) > _______________________________________________ > varnish-misc mailing list > varnish-misc at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kokoniimasu at gmail.com Mon Nov 22 07:24:08 2021 From: kokoniimasu at gmail.com (kokoniimasu) Date: Mon, 22 Nov 2021 16:24:08 +0900 Subject: A tool to package VMOD easily In-Reply-To: References: Message-ID: Thanks, It's something I've always wanted too :) 2021?11?22?(?) 15:06 Guillaume Quintard : > Sweet! I've been meaning to build something like that for a long time, > that's great! > > On Sun, Nov 21, 2021, 21:22 kokoniimasu wrote: > >> Hi, All. >> >> I've been struggling for a long time to deploy VMOD in my environment. >> So I created a tool to build a VMOD package easily. >> The Package is intended to be installed in its own environment, and >> supports deb and rpm. >> >> >> ``` >> xcir at build01:~/git/vmod-packager$ ./vmod-packager.sh -d focal -v 7.0.0 >> -e 0.19 varnish-modules >> ... >> ################################################## >> docker image: vmod-packager/focal:7.0.0-1 >> Dist: focal >> Varnish Version: 7.0.0 >> Varnish VRT: 140 >> VMOD name: varnish-modules >> VMOD Version: 140.0.19 >> Status: SUCCESS >> >> xcir at build01:~/git/vmod-packager$ ls pkgs/debs/varnish-modules/ >> varnish-modules_140.0.19~focal-1_amd64.build >> varnish-modules_140.0.19~focal-1_amd64.changes >> varnish-modules-dbgsym_140.0.19~focal-1_amd64.ddeb >> varnish-modules_140.0.19~focal-1_amd64.buildinfo >> varnish-modules_140.0.19~focal-1_amd64.deb >> ``` >> >> It's still under development, but I think it will work. >> >> https://github.com/xcir/vmod-packager >> >> Regards, >> >> -- >> Shohei Tanaka(@xcir) >> https://blog.xcir.net/ (JP) >> _______________________________________________ >> varnish-misc mailing list >> varnish-misc at varnish-cache.org >> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: