0

如果这看起来很愚蠢,请提前对 Varnish 完全的新手道歉。

这是情况。我有一个有 5 个 IP 的服务器。将 ISPconfig 用于大多数任务,但这可能无关紧要。

我有多个跨多个 IP 配置的 apache 虚拟主机。

问题是 varnish 在任何非默认虚拟主机(即在 vhosts 中定义了静态 IP 的虚拟主机)上发出 503,获取错误无后端连接(根据 varnishlog)。任何 *:8080 虚拟主机都可以正常工作。所以我在某处遗漏了一些东西。尽管路径看起来正确,但所有 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)") {

.......
'
4

1 回答 1

1

当然是显而易见的事情。

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
于 2012-08-31T17:41:21.400 回答