varnish引用外部文件(varnish referencing an external file)

编程入门 行业动态 更新时间:2024-10-27 19:22:28
varnish引用外部文件(varnish referencing an external file)

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

更多推荐

本文发布于:2023-07-14 23:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1108323.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   varnish   referencing   file   external

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!