3
我已經安裝了Apache和Tomcat,並希望在它們前面安裝Varnish,靜態去Apache和動態去Tomcat(所有/靜態/ *網址去Apache,應該由Varnish緩存,其他網址去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的答案設置後端,不需要返回(查找):行。默認的VCL將被附加並且具有該功能。 – lkarsten