Discourse, Apache 和 Varnish Cache 的问题

你好!
我正在为 Discourse Docker 使用反向代理,因为我的主系统上还托管着其他网站。我在 Apache 前端前面部署了 Varnish 缓存,以加快网站加载速度。有时(登录后)我会随机遇到“503 Backend fetch failed”错误。这个问题是随机出现的,例如:点击邮件中的链接时会报错,注册时也会出现同样的问题。这只是我遇到的几个例子。有人知道如何修复吗?或者如何针对某个网站禁用 Varnish 缓存?

谢谢,
Kian

我好像自己解决了这个问题。我在我的 .vcl 文件中禁用了 probe,这似乎解决了 503 错误。附上我的 Varnish .vcl 文件,以防有人需要(也许对你也有效)!:slight_smile:

vcl 4.0;

backend default {
    .host = "127.0.0.1";
    .port = "81";
    .connect_timeout = 5s;
    .first_byte_timeout = 10s;
    .between_bytes_timeout = 10s;
}
sub vcl_recv{
  unset req.http.Cookie;
if (req.http.host ~"forum.thelostworldmc.com") {
   if (!(req.url ~ "(^/uploads/|^/assets/|^/user_avatar/)")) {
      return (pass);
   }
}
}
sub vcl_deliver {
  if (obj.hits > 0) {
    set resp.http.X-Cache = "HIT";
  } else {
    set resp.http.X-Cache = "MISS";
  }
}
2 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.