清漆引用外部文件
varnish referencing an external file
我是 varnish 的新手,我正在尝试找出一种方法,让 varnish 可以引用外部 html 文件来提供错误页面,因为 html 代码在合成函数会太复杂,因为错误页面有太多可视化,谢谢
如果您使用的是 Varnish 4(或更新版本),您可以使用 std vmod
请参阅文档: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);
}
}
我是 varnish 的新手,我正在尝试找出一种方法,让 varnish 可以引用外部 html 文件来提供错误页面,因为 html 代码在合成函数会太复杂,因为错误页面有太多可视化,谢谢
如果您使用的是 Varnish 4(或更新版本),您可以使用 std vmod 请参阅文档: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);
}
}