Hi Tharanga, You seem to be a bit confused about how the directors and backends work in Varnish. Please read this:
https://www.varnish-cache.org/docs/trunk/users-guide/vcl-backends.html#backends-and-virtual-hosts-in-varnish Note that the .host property of the backend has NOTHING to do with the virtual host. On Fri, Aug 30, 2013 at 2:02 AM, Tharanga Abeyseela < [email protected]> wrote: > Hi Per, > > Thanks for the reply. Actually my set up looks like this. > > > cluster.com - 192.168.0.200 (varnish/port 80) > xxx.com - 192.168.0.100 (apache,namebased vhost/8080 - backendname - > website) > yyy.com - 192.168.0.100 (apache,namebased vhost/8080 -backendname - api) > > cluster.com is the varnish server and front-end connections coming to > this and rewrite to other defined back-ends (round-robin based balancing) > > > backend website { > .host = "xxx.com"; > .port = "8080"; > > } > backend api { > .host = "yyy.com"; > .port = "8080"; > > } > > director clust round-robin { > { .backend = api; } > { .backend = website; } > > } > > sub vcl_recv { > set req.backend = clust; > if (req.request) > { > return(pass); > } > > } > > > when i hit the cluster.com , it is always going to xxx.com, but what i > need to do is first request go to xxx.com second request yyy.com and so > on...when i add another server (different host/different IP say > 192.168.0.111/zzz.com, and a different backend) , it goes like this > > first request - xxx.com > second request - xxxx.com > third request - zzz.com > > > but i can change the default behavior by setting up set req.host = yyy.comand > then it will goes to > first request - yyy.com > second request - yyy.com > third request - zzz.com > > 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 ? > appreciate your help on this, this is working perfectly with other servers > (different servers, not with namebased vhosts) > > cheers, > Tharanga > > > > > > > > > > > > > > > > On Thu, Aug 29, 2013 at 11:58 PM, Per Buer <[email protected]>wrote: > >> Hi mate, >> >> On Thu, Aug 29, 2013 at 3:17 PM, Tharanga Abeyseela < >> [email protected]> wrote: >> >>> (..) >>> >>> But how should i send host-headers to varnish to redirect to the correct >>> server, This is always going to xxx.com. >>> >> >> You don't. :-) >> >> 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. >> >> So, if you have two vhosts handled by "website" you just set that as the >> backend in vcl_recv. >> >> -- >> <http://www.varnish-software.com/> *Per Buer* >> CTO | Varnish Software AS >> Phone: +47 958 39 117 | Skype: per.buer >> We Make Websites Fly! >> >> Winner of the Red Herring Top 100 Europe Award 2013 >> >> >> > -- <http://www.varnish-software.com/> *Per Buer* CTO | Varnish Software AS Phone: +47 958 39 117 | Skype: per.buer We Make Websites Fly! Winner of the Red Herring Top 100 Europe Award 2013
_______________________________________________ varnish-misc mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
