<div dir="ltr"><div>Hi all,</div><div><br></div><div>Turns out install-vmod works, just needed to grab the right tarballs and have the right dependencies installed. Here's the Dockerfile I used:<br><div style="margin-left:40px"><span style="font-family:monospace">FROM varnish:7.3<br><br>USER root<br>RUN set -e; \<br> EXTRA_DEPS="autoconf-archive libossp-uuid-dev"; \<br> apt-get update; \<br> apt-get -y install $VMOD_DEPS $EXTRA_DEPS libossp-uuid16 libuuid1 /pkgs/*.deb; \<br> # vmod_querystring<br> install-vmod <a href="https://github.com/Dridi/libvmod-querystring/releases/download/v2.0.3/vmod-querystring-2.0.3.tar.gz">https://github.com/Dridi/libvmod-querystring/releases/download/v2.0.3/vmod-querystring-2.0.3.tar.gz</a>; \<br> # vmod_uuid<br> install-vmod <a href="https://github.com/otto-de/libvmod-uuid/archive/refs/heads/master.tar.gz">https://github.com/otto-de/libvmod-uuid/archive/refs/heads/master.tar.gz</a>; \<br> apt-get -y purge --auto-remove $VMOD_DEPS $EXTRA_DEPS varnish-dev; \<br> rm -rf /var/lib/apt/lists/*<br>USER varnish</span></div></div><div><br></div><div>and here's the VCL:</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace">vcl 4.1;<br><br>import querystring;<br>import uuid;<br><br>backend default {<br> .host = "localhost";<br> .port = "4444";<br>}<br><br>sub vcl_init {<br> new qf = querystring.filter(sort = true);<br> qf.add_string("myparam");<br>}<br><br># clear the url from param as it goes in<br>sub vcl_recv {<br> # clear myparam from the incoming url<br> set req.url = qf.apply(mode = drop);<br>}<br><br># add the querystring parameter back if we go to the backend<br>sub vcl_backend_fetch {<br> # create the unique string<br> set bereq.http.mynewparam = regsub(uuid.uuid_v4(), "^(.{20}).*", "\1");<br><br> # add our own myparam<br> if (bereq.url ~ "\?") {<br> set bereq.url = bereq.url + "&myparam=" + bereq.http.mynewparam;<br> } else {<br> set bereq.url = bereq.url + "?myparam=" + bereq.http.mynewparam;<br> }<br>}</span></div><div><br></div><div>It's a bit crude, but it fulfills your requirements. Make sure you test it though.<br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>-- <br></div><div>Guillaume Quintard<br></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 1, 2023 at 6:10 AM Uday Kumar <<a href="mailto:uday.polu@indiamart.com">uday.polu@indiamart.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for the prompt response!<div><br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><font color="#000000">Thanks & Regards</font><div><font color="#000000">Uday Kumar</font></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 1, 2023 at 11:12 AM Guillaume Quintard <<a href="mailto:guillaume.quintard@gmail.com" target="_blank">guillaume.quintard@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks, so, to make things clean you are going to need to use a couple of vmods, which means being able to compile them first:<div>- <a href="https://github.com/otto-de/libvmod-uuid" target="_blank">https://github.com/otto-de/libvmod-uuid</a> as Geoff offered</div><div>- <a href="https://github.com/Dridi/libvmod-querystring" target="_blank">https://github.com/Dridi/libvmod-querystring</a> that will allow easy manipulation of the querystring</div><div><br></div><div>unfortunately, the install-vmod tool that is bundled into the Varnish docker image isn't able to cleanly compile/install them. I'll have a look this week-end if I can, or at least I'll open a ticket on <a href="https://github.com/varnish/docker-varnish" target="_blank">https://github.com/varnish/docker-varnish</a></div><div><br></div><div>But, if you are able to install those two, then your life is easy:</div><div>- once you receive a request, you can start by creating a unique ID, which'll be the the vcl equivalent of `uuidgen | sed -E 's/(\w+)-(\w+)-(\w+)-(\w+).*/\1\2\3\4/'` (without having testing it, probably `regsub(uuid.uuid_v4(), "s/(\w+)-(\w+)-(\w+)-(\w+).*", "\1\2\3\4/"`)</div><div>- then just add/replace the parameter in the querystring with vmod_querystring</div><div><br></div><div>and...that's about it?</div><div><br></div><div>Problem is getting the vmods to compile/install which I can help with this week-end. There's black magic that you can do using regex to manipulate querystring, but it's a terrible idea.</div><div><br></div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>-- <br></div><div>Guillaume Quintard<br></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 31, 2023 at 6:48 PM Uday Kumar <<a href="mailto:uday.polu@indiamart.com" target="_blank">uday.polu@indiamart.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Does it need to be unique? can't we just get away with "aaaaaaaaaaaaaaaaaaaa"?</div></blockquote><div> </div>Our Requirements:<br>1. New Parameter should be <b>appended </b>to already existing parameters in Query String. (should not replace entire query string)<br>2. Parameter Value <b>Must be Unique for each request</b> (ideally unique randomness is preferred)<br>3. Allowed Characters are Alphanumeric which are <b>URL safe</b> [can be lowercase, uppercase in case of alphabets]<br>4. Characters can be repeated in parameter value EX: Gn4lT<b>Y</b>gBgpPaRi6hw6<b>Y</b>S (here, Y is repeated) But as mentioned above the value must be unique as a whole.<br><br>Ex: Parameter value for 1st request can be "Gn4lT<b>Y</b>gBgpPaRi6hw6<b>Y</b>S",<br><div> 2nd request can be "G34lTYgBgpPaRi6hyaaF" and so on </div><div><br></div><div><br></div><div>Thanks & Regards</div><div>Uday Kumar</div></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>