Configuration varnish cache for multiple domain

Bjørn Ruberg bjorn at ruberg.no
Mon Jan 24 07:21:12 CET 2011


On 01/24/2011 05:40 AM, Hari Metkari wrote:
> Hi,
>
>
> I am implementing varnish cache for multiple seprate domain.i.e
> sitetwo.com <http://sitetwo.com> and site3.com <http://site3.com>
>
> I am configured varnish cache on varnish server local ip address
> (192.168.126.30)
> and my one site ip address 192.168.126.20 and two site ip address
> 192.168.126.60
>
> I added multiple backend in VCL file.when I hit site one it calls to
> backend of site two instead of backend one.
> for single domain it's working fine but multiple domain not work.

What do you mean by "not work"? Please describe what happens. The best 
evidence is an extract from varnishlog showing the transactions, both 
successful ones and failed ones.

[...]

> 2) /etc/varnish/default.vcl  file
>
> backend site2 {
>        .host = "sitetwo.com <http://sitetwo.com>";
>        .port = "8081";
> }
> backend site3 {
>        .host = "site3.com <http://site3.com>";
>        .port = "8080";
> }

I suggest you use plain text when posting code, not HTML.

[...]

> if (req.http.host == "site3.com <http://site3.com>") {
>          #You will need the following line only if your backend has
> multiple virtual host names
>          set req.http.host = "site3.com <http://site3.com>";
>          set req.http.X-Orig-Host = req.http.host;
>          set req.backend = site3;
>          return (lookup);
> }
> if (req.http.host == "sitetwo.com <http://sitetwo.com>") {
>          #You will need the following line only if your backend has
> multiple virtual host names
>          set req.http.host = "sitetwo.com <http://sitetwo.com>";
>          set req.http.X-Orig-Host = req.http.host;
>          set req.backend = site2;
>          return (lookup);
> }

I'm unsure whether "return (lookup)" is a good idea at this stage. Apart 
from that, the above should work as long a the clients use the exact 
hostnames mentioned in your config. E.g. www.site3.com will fall through.

Without varnishlog evidence, there's not more we can do.

-- 
Bjørn





More information about the varnish-misc mailing list