3

我已经安装了 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);
}
4

1 回答 1

4

根据Varnish 文档,使用

set req.backend = static;

等等。

于 2012-12-10T09:05:25.003 回答