Varnish 3 - choose backend based on header field.

Mad Indian themadindian at yahoo.com
Sun Jan 20 16:54:15 CET 2013


You could try with two backends named app1 and app2 and app_dir as the default director

if (req.http.X-AppServer == "app1") {
                set req.backend = app1;
        } else if (req.http.X-AppServer == "app2") {
                set req.backend = app2;
        } else {
                set req.backend = app_dir;
        }




________________________________
 From: Rafał Radecki <radecki.rafal at gmail.com>
To: varnish-misc at varnish-cache.org 
Sent: Friday, January 11, 2013 4:16 AM
Subject: Varnish 3 - choose backend based on header field.
 
Hi all.

I currently use varnish 3 in my environment. I use client director
with two backends. I use set client.identity = client.ip to connect
client session with backend.
I would like to have the possibility to choose specific backend (first
or second) based on the presence of a header in http request. If my
request would have a header X-AppServer = app1 varnish should forward
the request to the first application server if X-AppServer = app2 to
the second and if there would be no such header it should use default
client director. Is it possible in varnish 3?

Best regards,
Rafal.

_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130120/3462de40/attachment.html>


More information about the varnish-misc mailing list