Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to specify a weight for a backend in Varnish? I need to be able to serve different page if my main backend is unaccessable.

share|improve this question
up vote 1 down vote accepted

If you have varnish in front of a single backend, you can define the 503 page that is displayed when the backend isn't reachable. You could increase your grace time so that you serve old content if the backend fails.

If you have varnish in front of two backends, you can define a director with healthchecks that will remove the bad backend, leaving the other backend responding.

You can also intercept the 503 to report a page from a separate backend that has a static page. The directors don't really support weights, but since VCL is just compiled C code, there really isn't much you can't do. You can see if the beresp object is an error and select a different backend, perhaps the one for your error message.

Unless you're running varnish in front of a webfarm, putting the 503 page in Varnish is probably the easiest.

share|improve this answer
I've tried going with director and I intentionally brought one of the backends down, yet varnish still serving content from backend that isn't responding. unless i didn't do it right inside of default.vcl configuration file. I even gave 1 weight to backend that I want to serve just 503 page and 10 to my real website. Where can I find a good example for creating 503 custom page? – alexus Oct 13 '10 at 21:42… has some snippets that you can use. Then you could define a known-good backend, and check req.backend.healthy and set the backend to your failmessage backend. – karmawhore Oct 13 '10 at 21:46

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.