Posted by Baber Javed on May 3, 2012 at 11:04am
I've been trying out several VCL files across the web but my problem seems to be a bit different. I have several websites (Rails + PHP) running on my server on Nginx + PHP-FDM on port 80 and I need to setup Varnish for one of my Drupal websites only so I obviously cannot change the port 80 to be used by Varnish as all the other sites will go down as well.
Any Ideas what my VCL file should look like in this case? (PHP-FDM is running on port 9000)
Comments
Make sure you're using
Make sure you're using varnish 3.0 from the varnish repository, the 'native' packages are quite out of date.
Either start varnish on a separate interface and migrate the DNS for your sole drupal site or route all traffic through varnish, bind nginx to a different port or localhost only and write some custom VCL to select the correct backend depending on the host header.
e.g.
backend php {
.host = "127.0.0.1";
.port = "9000";
}
backend rails {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.http.host ~ "my-example-php-site.com$") {
set req.backend = php;
}
else {
set req.backend = rails;
}
.....
}
The above isn't a complete solution, you'll need to read this:
https://www.varnish-cache.org/docs/3.0/reference/vcl.html
http://www.linkedin.com/in/linuxwizard
Thanks
Thanks, finally got it working. But for some reason some of the pages always report a MISS for X-Varnish-Cache, why would that be.
P.S I've got it working on the website www.pakreviews.com
When I visit the homepage I
When I visit the homepage I get:
Via 1.1 varnishX-Drupal-Cache MISS
X-Generator Drupal 7 (http://drupal.org)
X-Powered-By PHP/5.3.10
X-Varnish 553209247 553208211
X-Varnish-Cache HIT
You probably just need to clear your cookies after logging out as by default varnish will pass any requests with a Set-Cookie header and thus generate a MISS.
http://www.linkedin.com/in/linuxwizard