Multiple virtual host with different IP's

dhanushka ranasinghe parakrama1282 at gmail.com
Tue Sep 25 09:31:07 CEST 2012


Hi..guys

Thanks for the help, i creared the default.vcl with multiple back-ends ,
now my varnish is working fine can access both content.com and
content.orgsites without any problem , This is my configuration , is
there any tips
[configuration changes ] to get maxim performance  or is there any draw
backs in this configuration...

configuration
--------------------

backend bkcachecom {
    .host = "10.100.1.1";
    .port = "8080";
}


backend bkcacheorg {
    .host = "10.100.1.2";
    .port = "8080";
}


sub vcl_recv {

if (req.http.host ~ "^a.content.org$") {
        set req.backend = bkcacheorg;
        return (lookup);
}

else if (req.http.host ~ "^b.content.org$") {
        set req.backend = bkcacheorg;
        return (lookup);
}

else if (req.http.host ~ "^a.content.com$") {
        set req.backend = bkcachecom;
        return (lookup);
}

else if (req.http.host ~ "^b.content.com$") {
        set req.backend = bkcachecom;
        return (lookup);
}

sub vcl_fetch {
     if (!beresp.cacheable) {
                        unset beresp.http.expires;
                        set beresp.http.cache-control = "max-age=900";
                        set beresp.ttl = 1w;
                        set beresp.http.magicmarker = "1";
         return (pass);
     }
     if (beresp.http.Set-Cookie) {
         return (pass);
     }
     return (deliver);
 }
 sub vcl_deliver {
     return (deliver);
 }


Thanks in Advance

Thank You


On 24 September 2012 21:34, Robert Socha <socha at socha.it> wrote:

> Hi
>
>
> W dniu 2012-09-24 16:11, dhanushka ranasinghe pisze:
> > Hi  guys ,
> > With follwing configuration   varnish only cache the content of the
> > *content.org <http://content.org> * , its not caching the *content.com
> > <http://content.com>* , Do i need to define multiple back-ends for each
> > virtual-hosts, can any one giude me how to do that .Or do i need to
> > configure  separate Varnish instance for each VHOST.
> >
>
> You need define multiple backends. No need for separate instances.
>
>
>
>
> > server {
> >     listen      10.100.1.1:8080 <http://10.100.1.1:8080>;
> >     server_name   content.com <http://content.com>;
> ...
>
> backend bkcontentcom {
>      .host = "10.100.1.1";
>      .port = "8080";
> }
>
>
> >  server {
> >                 listen      10.100.1.2:8080 <http://10.100.1.2:8080>
> >                 server_name  cache.org <http://cache.org>;
> ...
>
> backend bkcacheorg {
>      .host = "10.100.1.2";
>      .port = "8080";
> }
>
> And in the begining of vcl_recv()
>
> if (req.http.host ~ "^(www\.)?content\.com$") {
>         set req.backend = bkcontentcom;
> } else {
>         // for cache.org
>         set req.backend = bkcacheorg;
> }
>
>
>
> And of course your backends need to provide correct Cache-Control
> headers (ie. max-age or s-max-age).
>
> Greetings
> --
> Robert Socha
>
>
>
> _______________________________________________
> 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/20120925/c8e157d5/attachment.html>


More information about the varnish-misc mailing list