Varnish not respecting pass to backend for specified http hosts
Dridi Boukelmoune
dridi at varni.sh
Tue Mar 31 22:06:05 UTC 2020
On Tue, Mar 31, 2020 at 9:58 PM Guillaume Quintard
<guillaume at varnish-software.com> wrote:
>
> Hi,
>
> I think there is a bit of confusion regarding what "return(pass)" does.
>
> Basically, when a request comes in, you need to answer two questions:
> - do I want to cache it?
> - if I need data from the backend, well, what is my backend?
>
> "return(pass)" answers the first question with a big fat "no", and this is what you see in your log ("VCL_call PASS" and "VCL_return pass"), the request will be fetched backend, but won't be stored in cache.
>
> You then need to decide where to fetch the data from, but in your vcl, you only have one backend, so everything comes from the same backend, what you want is to create a second backend, and do
>
> if ((req.http.host ~ "(domain.com) || (dev.domain.com)")) {
No matter how you look at it this if statement is broken.
You can either go for this:
> if (req.http.host ~ "^(dev\.)?domain\.com")
Or you can do this:
> if (req.http.host == "domain.com" || req.http.host == "dev.domain.com")
The ~ operator in this context matches regular expressions, and your
regex doesn't make sense.
Dridi
> set req.backend_hint = default;
> } else {
> set req.backend_hint = other;
> return (pass);
> }
>
>
> Hopefully that will clarify things a bit.
>
> Out of curiosity, are you using the official varnish image (https://hub.docker.com/_/varnish) or something else?
>
> Cheers,
>
> --
> Guillaume Quintard
More information about the varnish-misc
mailing list