req.url modified in restart?

Dridi Boukelmoune dridi at
Wed Apr 26 15:46:27 CEST 2017

On Wed, Apr 26, 2017 at 3:31 PM, Jesper Larsen <jla at> wrote:
> Hi Varnish people
> I use something like this snippet:
> sub vcl_recv {
>     if (req.url ~ "^\/foo\/") {
>         set req.url = regsub(req.url, "^\/foo\/", "/");
>         set req.backend_hint = special_backend;
>     }
> }
> for rewriting req.url before sending the request to the backend. As you can see I simply remove the first portion of the path before sending the request to the backend. For urls not matching the regex I do not change req.url. I have also enabled restarts. I am using the original url in vcl_hash.
> But I have noticed that when the "special_backend" is down my default backend gets the request. I suppose the reason is that I have modified req.url. And when the request is restarted it uses this modified url which does not start with "/foo/".
> My question is: What would you recommend that I do to avoid this? Should I modify the url in another subroutine?

Hello Jesper,

Could you please describe in more details how to reproduce? Ideally
with just enough VCL. Possibly with the offending transaction's logs.

Please also mention Varnish's version.


More information about the varnish-misc mailing list