Varnish not respecting pass to backend for specified http hosts

Stephen Reese rsreese at gmail.com
Tue Mar 31 22:53:11 UTC 2020


On Tue, Mar 31, 2020 at 5:56 PM Guillaume Quintard
<guillaume at varnish-software.com> wrote:

> 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

This cleared things up, the following seems to work in that it will
not cache requests for the two domains but appears to cache everything
I would like to:

        if ( req.http.host == "domain.com" || req.http.host ==
"dev.domain.com") {
                return (pass);
        } else {
                set req.backend_hint = default;
        }

Or since I only have one backend:

        if ( req.http.host == "domain.com" || req.http.host ==
"dev.domain.com") {
                return (pass);
        }

> Out of curiosity, are you using the official varnish image (https://hub.docker.com/_/varnish) or something else?

I am using the official Varnish image from the aforementioned link,
works great! Nginx -> Varnish -> Nginx -> PHP-FPM. With fairly heavy
Wordpress theme and plugins, site will sees ~1-3k ms DOMContentLoaded
without Varnish and ~300ms with!


More information about the varnish-misc mailing list