varnish 5 and multiple domains

Guillaume Quintard guillaume at varnish-software.com
Wed Oct 26 10:43:55 CEST 2016


Hi,

Definitely not the first version, keep your includes at the top of
your file, where we can see them, something like:

in nl.vcl:
    sub nl_recv {
        do some stuff
    }

in com.vcl:
    sub com_recv {
        do some stuff
    }

in default.vcl:
   sub vcl_recv {
        if (req.http.Host == "www.example.nl") {
            call nl_recv;
        } else if (req.http.Host == "www.example.com") {
            call com_recv;
        }
   }

But since you are on 5, you can do something even sexier:
https://varnish-cache.org/docs/trunk/users-guide/vcl-separate.html
--
Guillaume Quintard


On Wed, Oct 26, 2016 at 10:03 AM, Admin Beckspaced <admin at beckspaced.com> wrote:
> dear varnish users ;)
>
> i'm new to varnish and got a question about how to best implement multiple
> domains into varnish 5
>
> i got quite a few domains hosted on my linux server and would like to
> include some domains, exclude others and also switch between different vcl's
> based on the domain.
>
> i've looked around on the internet but thought why not ask the mailing list
> pro's for advice ;)
>
> should i use the new load and label feature with version 5 as explained
> here:
>
> https://varnish-cache.org/docs/trunk/users-guide/vcl-separate.html
>
> or should i use the include feature as explained here:
>
> https://www.varnish-cache.org/lists/pipermail/varnish-misc/2011-January/019815.html
>
> e.g.
>
>        if (req.http.Host == "domainx.be") {
>            include "/etc/varnish/domainx.be.vcl";
>        }
>
> or, instead of include, should i put all in a single vcl file?
>
> sub vcl_recv {
>
> if (req.http.Host == "www.example.nl")
>  {
>    do some stuff;
>  }
>  elsif (req.http.Host == "www.example.com")
>  {
>    do some stuff;
>  }
>
> }
>
> which approach would you recommend for multiple domains?
>
> thanks for your hints & tips ;)
> becki
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list