2

Every time I attempt to add an extra back end into our VCL file, it's fails.

Here is the DAEMON_OPTS we are running off:

DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/custom.vcl \ -u varnish -g varnish \ -S /etc/varnish/secret \ -s malloc,10G"

And here is the offending backend(s)

backend b1 { .host = "114.123.456.789"; .port = "8080"; }

backend b2 { .host = "203.123.456.789"; .port = "80"; }

Any Ideas ? Gut feeling is it might need the backends to be set somewhere, but I'm not sure where.

Solved

So, it turns out I needed to set the backends in the vcl script, further down in the vcl file (vcl_recv). If this helps anyone else, this is the code that I copied from (https://www.varnish-cache.org/trac/wiki/VCLExampleRestarts)

sub vcl_recv {
            if (req.restarts == 0) {
                    set req.backend = b1;
            } else if (req.restarts == 1) {
                    set req.backend = b2;
            }
}
5
  • 1
    Can you clarify what the failure looks like? Does Varnish start with the problem config in place, or fail to start? If it's failing, what's logged? Sep 11, 2012 at 15:10
  • Varnish is failing to start at all. Have to revert back to a vcl with one backend to get it to restart. I'll see if there's anything in the logs now. Sep 11, 2012 at 15:17
  • Actually, the best place to look for errors during start is the binary's output. Your init script is probably sending stdout and stderr to /dev/null - temporarily tweak that to allow that output to be displayed, then try to start the service again? Sep 11, 2012 at 15:28
  • looked into varnish's own logs and /var/messages and couldn't find anything out the the ordinary. Sep 11, 2012 at 15:41
  • Right, you need to look at the output from the service start, not the logs. See my previous message. Sep 11, 2012 at 15:47

1 Answer 1

1

So, it turns out I needed to set the backends in the vcl script, further down. If this helps anyone else, this is the code that I copied from (https://www.varnish-cache.org/trac/wiki/VCLExampleRestarts)

sub vcl_recv {
            if (req.restarts == 0) {
                    set req.backend = b1;
            } else if (req.restarts == 1) {
                    set req.backend = b2;
            } else {
                    set req.backend = b3;
            }
}

Bizarre, but true

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .