Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Is (a variation of) this what you've tried already? varnish-software.com/blog/virtual-hosts-varnish –  jetboy Jun 25 '12 at 22:05
    
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 == "1.2.3.4") { ##------------------------------- 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.