[Varnish] #1502: if ( req.backend_hint == name-of-director ) { } not possible
Varnish
varnish-bugs at varnish-cache.org
Tue May 13 08:35:41 CEST 2014
#1502: if ( req.backend_hint == name-of-director ) { } not possible
--------------------------------+--------------------
Reporter: Tin | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: unknown | Severity: normal
Keywords: vmod_directors if |
--------------------------------+--------------------
In 3.0 it was possible to do something like
{{{
if ( req.backend == mydirector || req.backend == myotherdirector ) {
# do something very specific for these directors
}
}}}
Which is nice if you have over 100 directors and 1000's of director
related URL's.
In 4.0 this does not seem possible anymore as
{{{
vcl 4.0;
backend one { .host="127.0.0.1"; }
backend two { .host="127.0.0.1"; }
import directors;
sub vcl_init {
new apenootjes = directors.hash();
apenootjes.add_backend(one,1);
apenootjes.add_backend(two,1);
}
sub vcl_recv {
set req.backend_hint=apenootjes.backend(client.identity);
if ( req.backend_hint == apenootjes.backend(client.identity) ) {
return(lookup);
} else {
return(pass);
}
}
}}}
Will not even compile. Alternatives have been tried but won't compile
either.
A workaround is to define a specific X-header when addressing a director,
but that is not really nice.
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1502>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list