[Varnish 4] Custom Error Page from Backend

Kelvin Loke kelvin1111111 at gmail.com
Fri Oct 10 06:27:30 CEST 2014


It doesn't seem to work. Take the example of HTTP 404 from backend, it
actually goes to vcl_backend_response, not vcl_backend_error.

And unfortunately I am not allowed to use synthetic() in
vcl_backend_response. Inside vcl_backend_response I also thought of passing
a custom header beresp.http.X-CustomError = "YES" to vcl_deliver, but it's
the same result that I am not allowed to use synthetic() in vcl_deliver.



On Thu, Oct 9, 2014 at 11:45 PM, Per Buer <perbu at varnish-software.com>
wrote:

>
>
> 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/20141010/04f21a53/attachment.html>


More information about the varnish-misc mailing list