<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:10pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 10pt; "><span>You could try with two backends named app1 and app2 and app_dir as the default director</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><span><br></span></div><div style="background-color: transparent; "><span><div style="background-color: transparent; "><font size="2">if (req.http.X-AppServer</font><span style="font-size: 13px; background-color: transparent; "> == "app1") {</span></div><div style="background-color: transparent; "><font size="2"> set req.backend = app1;</font></div><div style="background-color: transparent; "><font size="2">
} else if (<font size="2">req.http.X-AppServer</font><span style="background-color: transparent; font-size: 13px; "> == "app2"</span>) {</font></div><div style="background-color: transparent; "><font size="2"> set req.backend = app2;</font></div><div style="background-color: transparent; "><font size="2"> } else {</font></div><div style="background-color: transparent; "><font size="2"> set req.backend = app_dir;</font></div><div style="background-color: transparent; "><font size="2"> }</font></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 13px; font-style: normal; "><br></div></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color:
transparent; font-style: normal; "><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 10pt; "><br></div> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 10pt; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> RafaĆ Radecki <radecki.rafal@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> varnish-misc@varnish-cache.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Friday, January 11, 2013 4:16 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Varnish 3 - choose backend based on header field.<br> </font> </div> <br>
Hi all.<br><br>I currently use varnish 3 in my environment. I use client director<br>with two backends. I use set client.identity = client.ip to connect<br>client session with backend.<br>I would like to have the possibility to choose specific backend (first<br>or second) based on the presence of a header in http request. If my<br>request would have a header X-AppServer = app1 varnish should forward<br>the request to the first application server if X-AppServer = app2 to<br>the second and if there would be no such header it should use default<br>client director. Is it possible in varnish 3?<br><br>Best regards,<br>Rafal.<br><br>_______________________________________________<br>varnish-misc mailing list<br><a ymailto="mailto:varnish-misc@varnish-cache.org" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc"
target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br><br><br> </div> </div> </div></body></html>