<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi Per,<br><br></div>Thanks for the reply. Actually my set up looks like this.<br><br><br></div><a href="http://cluster.com">cluster.com</a> - 192.168.0.200 (varnish/port 80)<br>
</div><a href="http://xxx.com">xxx.com</a> - 192.168.0.100 (apache,namebased vhost/8080 - backendname - website)<br></div><a href="http://yyy.com">yyy.com</a> - 192.168.0.100 (apache,namebased vhost/8080 -backendname - api)<br>
<br></div><div><a href="http://cluster.com">cluster.com</a> is the varnish server and front-end connections coming to this and rewrite to other defined back-ends (round-robin based balancing)<br></div><div><span class="" style="border-collapse:separate;color:rgb(0,0,0);font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><pre style="white-space:pre-wrap">
backend website {
.host = "<a href="http://xxx.com">xxx.com</a>";
.port = "8080";
}
backend api {
.host = "<a href="http://yyy.com">yyy.com</a>";
.port = "8080";
}
director clust round-robin {
{ .backend = api; }
{ .backend = website; }
}
sub vcl_recv {
set req.backend = clust;
if (req.request)
{
return(pass);
}
}
</pre></span><br class=""></div>when i hit the <a href="http://cluster.com">cluster.com</a> , it is always going to <a href="http://xxx.com">xxx.com</a>, but what i need to do is first request go to <a href="http://xxx.com">xxx.com</a> second request <a href="http://yyy.com">yyy.com</a> and so on...when i add another server (different host/different IP say <a href="http://192.168.0.111/zzz.com">192.168.0.111/zzz.com</a>, and a different backend) , it goes like this<br>
<br></div>first request - <a href="http://xxx.com">xxx.com</a><br></div>second request - <a href="http://xxxx.com">xxxx.com</a><br></div>third request - <a href="http://zzz.com">zzz.com</a><br><br><br></div>but i can change the default behavior by setting up set req.host = <a href="http://yyy.com">yyy.com</a> and then it will goes to <br>
</div>first request - <a href="http://yyy.com">yyy.com</a><br>second request - <a href="http://yyy.com">yyy.com</a><br></div>third request - <a href="http://zzz.com">zzz.com</a><br><br></div>this is something to do with the host-header forwarding to the correct back-end. how should i add that functionality to the vcl_recv ?<br>
</div>appreciate your help on this, this is working perfectly with other servers (different servers, not with namebased vhosts)<br><br></div>cheers,<br></div>Tharanga <br><div><div><div><div><div><br> <br><div><div><div>
<div><div><div><div><br><br><br><br><br><div><div><div><div><br><br><br><br><br><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Aug 29, 2013 at 11:58 PM, Per Buer <span dir="ltr"><<a href="mailto:perbu@varnish-software.com" target="_blank">perbu@varnish-software.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi mate,<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 29, 2013 at 3:17 PM, Tharanga Abeyseela <span dir="ltr"><<a href="mailto:tharanga.abeyseela@gmail.com" target="_blank">tharanga.abeyseela@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">(..)<div class="im"><br>But how should i send host-headers to varnish to redirect to the correct server, This is always going to <a href="http://xxx.com" target="_blank">xxx.com</a>.<br>
</div></div></blockquote><div><br></div><div>You don't. :-)</div><div><br></div><div>You need to dispatch the request to the right backend in vcl_recv and have the backend handle that host. You could start rewriting the host in vcl_recv, but I would advise against it. </div>
<div><br></div><div>So, if you have two vhosts handled by "website" you just set that as the backend in vcl_recv.</div></div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div dir="ltr"><div style="color:rgb(34,34,34);font-size:12.727272033691406px;font-family:arial,sans-serif;margin:5px 15px 0px 0px;padding-bottom:5px">
<table style="text-align:start;font-size:12px;line-height:1.5em;font-family:'Helvetica Neue',Arial,sans-serif;color:rgb(102,102,102);width:550px;border-top-width:1px;border-top-style:solid;border-top-color:rgb(238,238,238);border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);margin-top:20px;padding-top:5px;padding-bottom:5px" border="0" cellpadding="0" cellspacing="0">
<tbody><tr><td style="font-family:arial,sans-serif;margin:0px" width="100"><a href="http://www.varnish-software.com/" style="color:rgb(17,85,204)" target="_blank"><img src="http://www.varnish-software.com/static/media/logo-email.png" style="float:left;margin-left:10px"></a></td>
<td style="font-family:arial,sans-serif;margin:0px"><b style="font-size:14px;color:rgb(34,34,34)">Per Buer</b><br>CTO | Varnish Software AS<br>Phone: <a href="tel:%2B47%20958%2039%20117" value="+4795839117" target="_blank">+47 958 39 117</a> | Skype: per.buer<br>
<span style="font-weight:bold">We Make Websites Fly!<br>
<br></span><span style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:14px;font-weight:bold">Winner of the Red Herring Top 100 Europe Award 2013<br></span><p style="margin:0px;line-height:normal;font-family:Helvetica">
<img src="https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg"></p><span style="font-weight:bold"><br></span></td></tr></tbody></table><div></div></div><div style="clear:both;color:rgb(34,34,34);font-size:12.727272033691406px;font-family:arial,sans-serif;margin:15px 0px">
</div></div>
</font></span></div></div>
</blockquote></div><br></div>