Backend definition in multiple VCL files in Varnish 5
Kurt Sultana
kurtanatlus at gmail.com
Thu May 4 14:33:38 CEST 2017
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.vcl*
*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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20170504/cd5deb3e/attachment.html>
More information about the varnish-misc
mailing list