Backend definition in multiple VCL files in Varnish 5

Nigel Peck np.lists at sharphosting.uk
Sat May 6 21:45:45 CEST 2017


You might try Stack Overflow if you're not having any luck on this list. 
There are a few folks who answer Varnish questions on there. Just tag it 
"varnish" and "varnish-vcl".

Nigel

On 06/05/2017 14:40, Kurt Sultana wrote:
> Ideas anyone? Any help is appreciated.
> 
> Thanks
> 
> On 4 May 2017 2:33 p.m., "Kurt Sultana" <kurtanatlus at gmail.com 
> <mailto:kurtanatlus at gmail.com>> wrote:
> 
>     Hi all,
> 
>     I'm a bit newish to Varnish though I do have some background. I have
>     a Varnish 5 instance connected to 2 backend servers (Magento 2
>     applications).
> 
>     I'm using the new Varnish 5 feature of loading multiple VCL files.
>     My ultimate problem is during purging however I'd like to ensure
>     things are set up correctly because documentation regarding multiple
>     VCL files in Varnish 5 is somewhat lacking.
> 
>     To keep things very simple for now, I'm going to use 1 backend
>     server in my example.
> 
>     So, I have a magento.vcl defined as follows:
> 
>     *vcl 4.0;*
> 
>     *import std;*
>     *
>     *
>     *# The minimal Varnish version is 4.0*
>     *# For SSL offloading, pass the following header in your proxy
>     server or load balancer: 'X-Forwarded-Proto: https'*
>     *
>     *
>     *backend default {*
>     *    .host = "127.0.0.1";*
>     *    .port = "8088";*
>     *}*
>     *
>     *
>     *include "/etc/varnish/common.vcl";*
> 
>     And a top.vcl
> 
>     *vcl 4.0;*
>     *
>     *
>     *import std;*
>     *
>     *
>     *backend default { .host = "127.0.0.1"; }*
>     *
>     *
>     *sub vcl_recv {*
>     *    if (req.http.host == "magento2.dev") {*
>     *        return (vcl(magento_vcl));*
>     *    }*
>     *}*
> 
>     Then I run
> 
>     *service varnish restart*
> 
>     *varnishadm*
> 
>     *vcl.load magento /etc/varnish/conf.d/magento.vc <http://magento.vc>l*
> 
>     *vcl.label magento_vcl magento*
> 
>     *vcl.load top /etc/varnish/top.vcl*
> 
>     *vcl.use top*
> 
>     *quit*
> 
> 
>     When I browse to magento2.dev, I get a backend fetch error after
>     some seconds. It's only when I go in magento.vcl and change the name
>     of the backend and make a backend hint that it works. See below:
> 
>     *vcl 4.0;*
> 
>     *import std;*
>     *
>     *
>     *# The minimal Varnish version is 4.0*
>     *# For SSL offloading, pass the following header in your proxy
>     server or load balancer: 'X-Forwarded-Proto: https'*
>     *
>     *
>     *backend magento {*
>     *    .host = "127.0.0.1";*
>     *    .port = "8088";*
>     *}*
>     *
>     *
>     *
>     sub vcl_recv {
>          set req.backend_hint = magento;
>     }
>     *
>     *
>     *
>     *include "/etc/varnish/common.vcl";*
>     *
>     *
>     Why should I be specifying a backend hint? Shouldn't Varnish be
>     loading a different VCL according to the host specified in top.vcl?
>     Or is there something wrong?
> 
>     Thanks in advance,
>     Kurt
> 
> 
> 
> 
> _______________________________________________
> 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