Varnish error for failed backend
Danila Vershinin
ciapnz at gmail.com
Sat Mar 31 12:36:41 UTC 2018
Hi Geoff,
Thank you. I understand about vcl_synth being used when getting 500 & 503 better :)
However, I’m also interested how can we distinguish backend errors while using grace mode and failed probe.
Suppose that you have configured grace mode and a health check against homepage. And homepage fails with 500.
The backend is marked as sick, then synthetic response (guru meditation) is delivered from vcl_backend_error with resp.status pre-filled to 503.
So there seems to be no way to do the same conditional error display in that case?
Best Regards,
Danila
> On 31 Mar 2018, at 14:25, Geoff Simmons <geoff at uplex.de> wrote:
>
> On 03/31/2018 10:21 AM, Danila Vershinin wrote:
>>
>> If a constant PHP error occurs in the backend and there is no cache -
>> we see Backend fetch failed.
> [...]
>
>> ... it always takes time to explain to the clients that the Varnish
>> is not to blame ...
> Welcome to Varnish administration! Such is the life.
>
> When the backend fetch fails, always look to the FetchError entry in the
> backend log, which diagnoses the problem. It helps with those conversations.
>
>> ... and ideally there would be a way to deliver different Varnish
>> error page for these 3 cases:>
>> * 500 error-ed backend
>> * 404-ed backend
>> * actual problem talking to the backend (HTTP etc.)
>
> Varnish can generate the response itself with vcl_synth -- when you see
> the Guru Meditation and "Backend fetch failed", you're seeing the
> buitlin.vcl version of vcl_synth.
>
> vcl_synth is called automatically for response codes 500 & 503, for 404
> or anything else, your VCL has to direct to there:
>
> sub vcl_deliver {
> if (resp.status == 404) {
> return (synth(404));
> }
> }
>
> So you could have something like this:
>
> sub vcl_synth {
> if (resp.status == 500) {
> synthetic("500 error-ed backend");
> }
> elsif (resp.status == 404) {
> synthetic("404-ed backend");
> }
> elsif (resp.reason == "Backend fetch failed") {
> synthetic("actual problem talking to the backend");
> }
> }
>
> Since I believe about Varnish 5.0 or so you can use also this syntax to
> generate the synthetic response (synthetic() works as well):
>
> set resp.body = "mumble";
>
> Of course you'll probably want to have HTML markup in the generated
> response -- look to the Guru Meditation in builtin.vcl's vcl_synth for
> an example.
>
>
> HTH,
> Geoff
> --
> ** * * UPLEX - Nils Goroll Systemoptimierung
>
> Scheffelstraße 32
> 22301 Hamburg
>
> Tel +49 40 2880 5731
> Mob +49 176 636 90917
> Fax +49 40 42949753
>
> http://uplex.de
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20180331/72dd1116/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20180331/72dd1116/attachment.bin>
More information about the varnish-misc
mailing list