i have two web web sites and i want to cache them with varnish. could i cache them on same varnish with using same port?

for example; www.domain1.com:80, www.domain2.com:80

link|improve this question
feedback

2 Answers

If your backends are different for each of the domains, you can do something like the following.

backend domaina_com {
.host = "1.2.3.4";
.port = "80";
}
backend domainb_com {
.host = "2.3.4.5";
.port = "80";
}

sub vcl_recv {
 if (req.http.host ~ "^domaina.com$") {
   set req.backend = domaina_com;
 }
 if (req.http.host ~ "^domainb.com$") {
   set req.backend = domainb_com;
 }

If your domains are on the same backend, it is just a matter of making sure that the .host that you connect to answers the request properly. i.e. NameVirtualHost 127.0.0.1:80 and make sure the configs for the domains are set to answer on 127.0.0.1:80.

link|improve this answer
It's important that you get the hostname checks right, since hosts could be in mixed case etc. Don't rely on the client behaving like a well-trained browser! – Christian Davén May 16 '11 at 8:04
feedback

Yes you can. Varnish is a reverse caching proxy. It will cache any number of web-sites configured as back-ends.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.