Varnish and Subdomains

Marc Fournier marc.fournier at camptocamp.com
Sun Jun 20 17:02:13 CEST 2010


Hello,

> tastykhana.in - for users of our site.
> client.tastykhana.in - for our clients which requires authentication.
> admin.tastykhana.in - for our call center which requires
> authentication.
> 
> After setting up varnish the user site tastykhana.in worked perfectly
> but the subdomains started redirecting to the parent domain
> tastykhana.in.

As your 3 websites seem to be hosted on the same backend, the only way
for your webserver to differentiate them is the "Host" HTTP header. Try
commenting out this line:

  set req.http.host = "tastykhana.in";

This will let the "Host" header from user's browser get passed to the
backend without getting altered by varnish.

> How do i prevent the subdomains from caching? as they require
> authentication and i have also added the check for Cookies which
> passes the request directly to backend server apache.

The default behaviour is to not cache documents with HTTP
authentication, so you shouldn't need to do anything. But if prefer,
you can always do something like this:

if (req.http.host == "client.tastykhana.in" ||
    req.http.host == "admin.tastykhana.in") {
    return (pass);
}

I hope this will help !
Marc





More information about the varnish-misc mailing list