Mailing List Archive

Serving static html when all backends are sick
Given the following code:

=========================================
sub vcl_synth {
  if (resp.status == 999) {
    set resp.status = 200;
    set resp.http.Content-Type = "text/html; charset=utf-8";
    synthetic( {"Static HTML"} );
    return(deliver);
  }
}

# Check if backend is healthy, otherwise, redirect
if (!std.healthy(req.backend_hint)) {
  return (synth(999, "All backends down."));
}

=========================================

Will the static page be served if ALL backends are down, or just when
the specific backend it got back from the backend_hint is down?

We want to be able to serve static html as a fallback if all backends
are down.

Is this the proper way to do this?

Thanks in advance!

- Thijs

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Serving static html when all backends are sick [ In reply to ]
A director is considered healthy is any of its backend is healthy, so if
you put a director in req.backend_hint, you're good.

--
Guillaume Quintard

On Wed, Dec 7, 2016 at 9:29 AM, Thijs Cramer <t.cramer@beslist.nl> wrote:

> Given the following code:
>
> =========================================
> sub vcl_synth {
> if (resp.status == 999) {
> set resp.status = 200;
> set resp.http.Content-Type = "text/html; charset=utf-8";
> synthetic( {"Static HTML"} );
> return(deliver);
> }
> }
>
> # Check if backend is healthy, otherwise, redirect
> if (!std.healthy(req.backend_hint)) {
> return (synth(999, "All backends down."));
> }
>
> =========================================
>
> Will the static page be served if ALL backends are down, or just when
> the specific backend it got back from the backend_hint is down?
>
> We want to be able to serve static html as a fallback if all backends
> are down.
>
> Is this the proper way to do this?
>
> Thanks in advance!
>
> - Thijs
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc