Keeping multiple cookies based on regex or prefix, with Varnish 6.0

Batanun B batanun at hotmail.com
Mon Nov 15 14:08:28 UTC 2021


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: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20211115/32a211d5/attachment.html>


More information about the varnish-misc mailing list