User-friendly error pages from Varnish

Mikko Ohtamaa picture Mikko Ohtamaa · May 11, 2011 · Viewed 8.1k times · Source

We are using Varnish at the front of Plone. In the case Plone goes down or serves an internal error we'd like to show a user-friendly static HTML page which some CSS styling + images. ("The server is being updated page")

How to configure Varnish to do this?

Answer

bwight picture bwight · Jan 21, 2013

Another simple way to do it is using the std vmod that comes with varnish. This is my preferred way to do it because I like having the error messages outside the configuration in case you want to have multiple responses for different status codes.

import std;

sub vcl_error {
    set obj.http.Content-Type = "text/html; charset=utf-8";
    synthetic std.fileread("/path/to/file.html");

    return (deliver);
}