[Varnish 4] Custom Error Page from Backend

Per Buer perbu at varnish-software.com
Thu Oct 9 17:45:08 CEST 2014


On Thu, Oct 9, 2014 at 4:58 PM, Kelvin Loke <kelvin1111111 at gmail.com> wrote:

> I used to be able to do it in Varnish 3, but it's no longer an easy task
> in Varnish 4 (or my weary mind stops me from figuring out).
>
> How can I customized the error page (403, 404, 500, etc) from backend and
> send to end users? I prefer not to let the public to view my application
> error content.
>

> In Varnish 3 I am able to return the error() and specify the customized
> error message in vcl_error. However in Varnish 4 I can't find any way to
> return the synth() in vcl_backend_response and vcl_backend_error and
> specify the custom message in vcl_synth().
>

Have a look at "builtin.vcl" in the distribution. You'll find:

# sub vcl_backend_error {
#     set beresp.http.Content-Type = "text/html; charset=utf-8";
#     set beresp.http.Retry-After = "5";
#     synthetic( {"<!DOCTYPE html>
# <html>
#   <head>


You should be able to override it.

-- 
*Per Buer*
CTO | Varnish Software AS
Cell: +47 95839117
We Make Websites Fly!
www.varnish-software.com
[image: Register now]
<http://info.varnish-software.com/varnish-summits-autumn-2014-registration>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20141009/f8084f93/attachment.html>


More information about the varnish-misc mailing list