我已经安装了 Apache 和 Tomcat,想在它们前面安装 Varnish,静态到 Apache,动态到 Tomcat(所有/static/* url 到 Apache,应该由 Varnish 缓存,其他 url 到 Tomcat )。
如何配置 Varnish ?
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);
}
最佳答案
关于varnish - 如何设置具有两个后端的 Varnish ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13794432/