[Varnish] #1633: Change backend director doesn't work
Varnish
varnish-bugs at varnish-cache.org
Fri Nov 21 15:18:28 CET 2014
#1633: Change backend director doesn't work
------------------------------+--------------------
Reporter: steven.raccourci | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 4.0.2 | Severity: normal
Keywords: director |
------------------------------+--------------------
First, thanks for Varnish !
However, something strange occures in version 4. Basically, I've got 3 web
backends, 1 for the admin users and the 2 others for the public traffic.
The choice of the cluster (admin / public) is done in vcl_recv, but it
doesn't seem to work. Users are sent to a cluster according to the content
of their cookies (PHP session or not)
The relevant parts of the VCL file are the following :
{{{
# Above is the backends declaration that properly work, plus the
"directors" import
sub vcl_init {
new cluster_public = directors.round_robin();
cluster_public.add_backend(backendf1);
cluster_public.add_backend(backendf2);
new cluster_admin = directors.round_robin();
cluster_admin.add_backend(backenda1);
}
...
sub vcl_recv {
set req.backend_hint = cluster_public.backend();
# Various things happens here, but no backend affectation
...
if (req.http.Cookie) {
# Forward to the backend admin if a session exists and disable
cache
if (req.http.Cookie ~ "SESS[a-z0-9]+") {
set req.backend_hint = cluster_admin.backend();
return (pass);
}
}
return (hash);
}
}}}
What happens is that every hit ends on a public backend despite the cache
disabling works (return (pass)).
I can provide some more of my VCL if it is needed.
All of my backend are marked as "healthy", are properly configured and
point to the right machines (ping-checked).
Is it possible that "set req.backend_hint = *.backend();" actually appens
a backend / directory instead of setting a single value ? I ran some tests
that says not, but I might be wrong.
What's more, when I only define once the backend like this :
{{{
if (req.http.Cookie ~ "SESS[a-z0-9]+") {
set req.backend_hint = cluster_admin.backend();
} else {
set req.backend_hint = cluster_public.backend();
}
}}}
It works like a charm. Am I missing something ?
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1633>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list