How can I tell Varnish to show a custom html error page instead of the default "Guru Meditation" message?
The Varnish FAQ suggests using vcl_error for this (and it's how I've done it):
This is the default VCL for the error page:
if you want a custom version, simply override the function in your config and replace the markup in the
If you want to have different markup for different error codes you can do that fairly easily too:
The default vcl code above (and in the official FAQ) is incorrect . Here is verbatim paste from default.vcl:
Note that the above answers are for Varnish 3. As the question does not not specify version information, it seems an appropriate time to include the answer for Version 4 also as it has changed.
Hopefully this will save people from reading the above answers and putting vcl_error into their V4 VCL :)
Builtin VCL for Varnish 4.0
Note also that if you want to throw an error from within your VCL, you no longer use the 'error' function, instead you would do:
Also, 413, 417 and 503 errors from the backend are autmatically routed through this funtion.