我是varnish的新手,我试图找出一种方法,其中清漆可以引用外部html文件来提供错误页面,因为合成函数中的html代码太复杂,因为错误页面太多了可视化,谢谢
I am new to varnish and I am trying to figure out a way in which varnish can reference to an external html file to serve an error page, as having the html code in the synthetic function would be too complex as the error page has too many visualizations, thanks
最满意答案
如果您使用的是Varnish 4(或更新版本),您可以使用std vmod执行此操作请参阅doc: https ://www.varnish-cache.org/docs/4.0/reference/vmod_std.generated.html#func-fileread
我认为vcl应该如下所示(未经测试):
vcl 4.0; import std; #other stuff sub vcl_synth { if (resp.status == 404) { set resp.http.Content-Type = "text/html;"; synthetic(std.fileread("/etc/varnish/404.html")); return (deliver); } }If you are using Varnish 4 (or more recent) you can do it with the std vmod See the doc : https://www.varnish-cache.org/docs/4.0/reference/vmod_std.generated.html#func-fileread
I think the vcl should look like the following (not tested) :
vcl 4.0; import std; #other stuff sub vcl_synth { if (resp.status == 404) { set resp.http.Content-Type = "text/html;"; synthetic(std.fileread("/etc/varnish/404.html")); return (deliver); } }更多推荐
发布评论