Possible to disable/inactivate a backend using VCL?

Guillaume Quintard guillaume.quintard at gmail.com
Fri Apr 14 15:52:41 UTC 2023


Hi Batanun,

I'm curious, if it's completely deactivated what's the benefit of having it
in the vcl?

To answer your question: cheat! Add this somewhere in your vcl:

sub vcl_recv {
    # the if statement will never work, but the backend is referenced, so
the compiler won't bother you
    if (false) {
        set req.backend_hint = you_deactivated_backend;
    }
}

You could also start varnish with `-p vcc_feature=-err_unref` but I don't
recommend it as it'll affect all the unreferenced symbols, even the ones
you may care about.

Hope that helps

-- 
Guillaume Quintard


On Fri, Apr 14, 2023 at 4:53 AM Batanun B <batanun at hotmail.com> wrote:

> Hi,
>
> We are currently working on a new feature that won't go live for several
> months still. This new feature has it's own backend in Varnish. Most of our
> VCL code is identical for all environments, and this code refers to the new
> backend, so it needs to be defined otherwise Varnish won't start. But in
> production we don't want to show anything of this feature. And we would
> like to have this backend completely disabled or inactivated in Varnish.
> Can we do that using VCL? Like forcing the health to be sick, or something
> similar. We would prefer to keep this inside the backend declaration if
> possible, and we would also prefer somethink not too "hackish" (like
> pointing it to a dead IP).
>
> Does Varnish has any recommended approach for this? I know there is a cli
> command to set the health, but as I said we would really prefer doing this
> using VCL only.
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20230414/b71870e9/attachment.html>


More information about the varnish-misc mailing list