custom 503 page

Michael Alger varnish at
Thu Oct 14 06:12:54 CEST 2010

On Wed, Oct 13, 2010 at 05:51:32PM -0400, alexus wrote:
> I need to create a custom 503 page from default.vcl, so that I can
> let my user know that I'm temporary unavailable instead of
> standard varnish's page.

If you're getting an error page from Varnish itself (with the
request XID) then you'll want to modify or add your own vcl_error()
and use the "synthetic" command to construct a response page. The
default VCL shows how to do this, but essentially:

  sub vcl_error {

    set obj.http.Content-Type = "text/html; charset=utf-8";

    synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"



    return (deliver);


You can also substitute a synthetic response in vcl_fetch() in
response to certain error codes from the server, if desired. I
personally keep restarting failed requests until I hit the limit at
which point vcl_error() is called to deal with it, but if you only
have one backend it may be cleaner to issue the nice error response
from vcl_fetch. This is assuming it's the server's error message
you're wanting to hide.

More information about the varnish-misc mailing list