Using user defined variable in backend definition?

Nils Goroll slink at
Tue Aug 25 15:22:45 UTC 2020

On 24/08/2020 19:42, Batanun B wrote:
> So, I would like something like this to work:

With the "constant" vmod from
you can do something like this

/* */

backend foo {

    .host = "";


sub vcl_init {

    new envbackend = constant.backend(foo);


and then in your main vcl include "environment.vcl", which points to some
variant of the above and do

sub vcl_backend_fetch {

    set bereq.backend = envbackend.get();


for more details on the constant vmod

You could do the same thing with a string and the host header or even use a
string and to turn that into a
backend at run time.

hf, Nils

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list