我想配置我的 varnish 服务器以根据主机名使用不同的 .vcl 配置。我在同一个服务器 apache+varnish 4.1.2 中安装了 wordpress 和 magento
这是我尝试创建的 default.vcl,但我需要为 wordpress 包含一个特定的 vcl?
vcl 4.0;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8888";
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don't need,
# rewriting the request, etc.
if (! req.http.Host) { error 404 "Need a host header"; }
set req.http.Host = regsub(req.http.Host, "^www\.", "");
set req.http.Host = regsub(req.http.Host, ":80$", "");
if (req.http.Host == "hostname1.com") { include "/etc/varnish/wordpress.vcl"; }
elsif (req.http.Host == "hostname2.com") {include "/etc/varnish/magento.vcl";}
}
sub vcl_backend_response {
}
sub vcl_deliver {
}