Using user defined variable in backend definition?
Nils Goroll
slink at schokola.de
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 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20200825/a85b23ad/attachment.html>
More information about the varnish-misc
mailing list