gpt4 book ai didi

error-handling - 如何自定义503错误- Varnish 4

转载 作者:行者123 更新时间:2023-12-03 07:40:52 28 4
gpt4 key购买 nike

如何自定义Varnish 4的“503后端提取失败”?

当它们进入合成阶段时,我正在自定义其他错误:

sub vcl_synth {
if (resp.status == 750) {
set resp.http.location = "http://mobile.cronica.com.ar/";
set resp.status = 302;
set resp.http.Action = "Redirect";
return(deliver);
}
if (resp.status == 751) {
set resp.status = 301;
set resp.http.location = "http://www." + req.http.host + req.url;
set resp.http.Action = "Redirect";
return(deliver);
}
else {
synthetic( {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>"} + resp.status + " " + resp.reason + {"</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>

</head>
<body style="background-color:#444; font-family: 'Oswald', sans-serif;">
<h1 style="color:#DD8363;">Error "} + resp.status + " " + {"</h1>
<p style="color:#5F88C4; ">"} + resp.reason + {"</p>
<h3 style="color:white;">CEPI Says</h3>
<p style="color:#bdb76b;">XID: "} + req.xid + {"</p>
<p style="color:#bdb76b;">Edge-Server: "} + server.hostname + {"</p>
<hr>
<p style="color:#65b042;">2.0</p>
</body>
</html>
"} );
return(deliver);
}

}

但是503错误似乎可以避免这种情况。

最佳答案

根据Varnish Processing States控件,应将backend_error()传递给vcl_synth(),但实际上,您看到的错误页面是在 backend_error() of builtin.vcl 中无条件传递的。您可以在此处自定义您的网页,也可以在vcl中添加sub vcl_backend_error { return(retry); }以强制跳转到vcl_synth(),这将与resp.status = 503一起使用。

关于error-handling - 如何自定义503错误- Varnish 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28193671/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com