【发布时间】:2016-01-01 19:03:58
【问题描述】:
我正在尝试让 Varnish 使用博客缓存两个不同的域,但是在添加第二个域后,前一个域停止工作,
基本设置如下:
backend default {
.host = "127.0.0.1";
.port = "81";
}
backend onedomain {
.host = "127.0.0.1";
.port = "81";
}
backend newdomain {
.host = "127.0.0.1";
.port = "81";
}
acl purge {
"localhost";
}
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.
#Bypass large files
if (req.http.x-pipe-mark && req.restarts > 0) {
return(pipe);
}
# all domains in here will return a "pass" which means they won't be cached
if (req.http.host ~ "(www\.)?(domain1.com|domain2.com)") {
return (pass);
}
#else check if something we're going to cache
else if(req.http.host ~ "(www\.)?(onedomain.nu)") {
set req.http.host = "onedomain.com";
set req.backend_hint = onedomain;
}
else if(req.http.host ~ "(www\.)?(newdomain.com)") {
set req.http.host = "newdomain.com";
set req.backend_hint = newdomain;
}
else {
return (pass);
}
Newdomain 加载正常,而 domain4 只是将我发送到无限重定向循环(根据 chrome 错误)
我在 pastebin 中添加了完整的配置:http://pastebin.com/J1Hb76dZ
我意识到 Varnish 本身不会发送任何重定向命令,该站点使用旧配置,只有当我尝试此操作时,其中一个网站才会出现重定向问题。
有没有人遇到过这种情况并可以建议怎么做?
【问题讨论】:
标签: wordpress apache caching blogs varnish