User-friendly error pages from Varnish

前端 未结 4 1892
说谎
说谎 2021-02-04 07:49

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 +

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 08:01

    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);
    }
    

提交回复
热议问题