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

With the "constant" vmod from https://code.uplex.de/uplex-varnish/varnish-objvar
you can do something like this


/* backends_X.inc.vcl */

backend foo {

    .host = "127.0.0.1";

}

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();

}


See
https://code.uplex.de/uplex-varnish/varnish-objvar/blob/master/src/vmod_constant.rst
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 https://github.com/nigoroll/libvmod-dynamic to turn that into a
backend at run time.


hf, Nils

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to