Search code examples
chef-infravarnishhaproxychef-recipevarnish-vcl

Varnish HAproxy cookbook


I am trying to write HAproxy + Varnish with apache running on backend nodes.

My question is, how do I write in the cookbook to tell haproxy or varnish to check (vcl for example for varnish) If the request is to static file send it to backend nodes role webserverS, and if it's dynamic send it to role webserverD.

The reason haproxy is at the front and not varnish is because not all the content should be cached..


Solution

  • You need a VCL file defining two back-ends, and then in your vcl_recv set the req.backend_hint to the appropriate back-end based on your criteria. See this article for more information.

    You can tell Varnish what to cache, and what not to cache, using VCL, so you don't need another layer on the front to achieve that. The Varnish book is free and gives details.