【问题标题】:varnish 3 and multiple IPs (virtualhosts) isn't working out too well for me清漆 3 和多个 IP(虚拟主机)对我来说效果不太好
【发布时间】:2012-08-25 21:58:09
【问题描述】:

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

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

我在多个 IP 上配置了多个 apache 虚拟主机。

问题是 varnish 在任何非默认虚拟主机(即在 vhosts 中定义了静态 IP 的主机)上都发出 503, fetch error no backend connection(根据 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)") {

.......
'

【问题讨论】:

  • 以下是清漆日志的摘录:VCL_call c miss fetch 11 FetchError c no backend connection 11 VCL_call c error deliver 11 VCL_call c deliver deliver 11 TxProtocol c HTTP/1.1 11 TxStatus c 503 11 TxResponse c Service Unavailable 我在这里遗漏了一些明显的东西。

标签: apache varnish vhosts varnish-vcl


【解决方案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-09-25
  • 2012-10-24
  • 1970-01-01
  • 2015-06-05
  • 1970-01-01
  • 1970-01-01
  • 2018-05-29
  • 2012-01-09
  • 2012-05-26
相关资源
最近更新 更多