完全是Varnish的新手,如果这看起来很愚蠢,请提前道歉。
情况是这样的。我有一个5个IP的服务器。大多数任务都使用ISPconfig,但这可能无关紧要。
我在多个IP上配置了多个apache虚拟主机。
问题是,varnish在任何非默认虚拟主机(即vhosts中定义了静态IP的虚拟主机)上发出503,fetch error no后端连接(根据varnishlog)。任何*:8080主机运行正常。所以我在某个地方遗漏了一些东西。所有的vhost错误日志都显示文件不存在错误,尽管路径看起来是正确的。
我们非常感谢您的建议。
我当然手动编辑了所有vhost条目,并相应地进行了配置,即
<VirtualHost 00.11.22.33:8080>
DocumentRoot /var/www/shop.example1.com/web
这是我的vcl配置
backend default {
.host = "127.0.0.1";
.port = "8080";
}
backend example1 {
.host = "00.11.22.33";
.port = "8080";
}
backend example2 {
.host = "11.22.33.44";
.port = "8080";
}
acl purge {
"localhost";
}
sub vcl_recv {
if (req.http.host ~ "(?i)^(www.)?example1.com")
{
set req.http.host = "www.example1.com";
set req.backend = example1;
}
if (req.http.Host ~ "shop.example2.com")
{
set req.http.Host = "shop.example2.com";
set req.backend = example2;
}
set req.grace = 2m;
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;s*)(_[_a-z]+|has_js)=[^;]*", "");
set req.http.Cookie = regsub(req.http.Cookie, "^;s*", "");
if (req.url ~ "/wp-(login|admin|cron)") {
return (pass);
}
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");
set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");
if (req.url ~ "wp-content/themes/" && req.url ~ ".(css|js|png|gif|jp(e)?g)") {
.......
'
当然是显而易见的。
port.conf具有:
NameVirtualHost *:8080
Listen 127.0.0.1:8080
它需要的是:
NameVirtualHost *:8080
Listen 127.0.0.1:8080
Listen my_IP1:8080
Listen my_IP2:8080