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