I wish to use varnish to put in front of an apache and a tomcat on the same server. Depending on the ip requested, it goes to a different backend. This works.

Now for most of the sites the default varnish logic will work just fine. However for some specific sites I wish to use custom VCL code.

I can test for host name and include config files for the specific domains, but this only works inside the individual methods recv etc.

Is there a way to include a complete set of instructions, in one file, per domain, without having to manage separate files for subdomain_recv, subdomain_fetch etc? And preferably without running seperate instances of varnish.

When I try to include a file on the "root level" of default.vcl, I get a compilation error.

Best regards, Michael

  • Is (a variation of) this what you've tried already? varnish-software.com/blog/virtual-hosts-varnish – jetboy Jun 25 '12 at 22:05
  • 1
    Yes exactly. Although my hope was that it'd be possible to include a file including all the subs recv, fetch, pipe etc for each host. but it looks like it won't allow me to have a control-structure at the main level: Starting HTTP accelerator: varnishd failed! Message from VCC-compiler: Expected one of 'acl', 'sub', 'backend', 'director', 'probe', or 'import' Found: 'if' at ('input' Line 17 Pos 1) if (server.ip == "") { ##------------------------------- So maybe the only way to do it is to have domain_recv.vcl and domain_fetch.vcl and then do the test for host in every sub? – Michael Sørensen Jun 26 '12 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.