【问题标题】:How to set up varnish with two backends?如何使用两个后端设置清漆?
【发布时间】:2012-12-10 17:05:25
【问题描述】:

我已经安装了 Apache 和 Tomcat,想在它们前面安装 Varnish,静态到 Apache,动态到 Tomcat(所有 /static/* url 到 Apache 并且应该被 Varnish 缓存,其他 url 到Tomcat)。

如何配置清漆?

backend static {
  .host = "127.0.0.1";
  .port = "8080";
}
backend dynamic {
  .host = "127.0.0.1";
  .port = "8081";
}
sub vcl_recv {
 if (req.url ~ "^/static/") { # How to determine which backend to go to, and cache it?
    return (lookup);         # return (static.lookup)?
 } else {
    return (lookup);
 }
 return (lookup);
}

【问题讨论】:

  • 您可以根据 Kekkis 的回答设置后端,不需要 return(lookup): 行。默认的 VCL 将被附加并具有它。

标签: varnish


【解决方案1】:

按照Varnish documentation,使用

set req.backend = static;

等等。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-24
    • 2017-07-21
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    • 2013-01-05
    • 2014-05-26
    • 2014-10-16
    相关资源
    最近更新 更多