【问题标题】:PURGE on a Varnish 3.0.3 cluster在 Varnish 3.0.3 集群上清除
【发布时间】:2012-11-14 04:50:49
【问题描述】:

我有一个网站 www.mysite.com 在负载平衡器后面运行。负载均衡器集群中有两台服务器。每个都运行 Varnish 3.0 和 Apache/PHP(我知道 varnish 可以为我实现负载平衡 - 但我们偏爱不同的 LB 技术)。

我时不时需要清除一两个 URL...

在我的 VCL 中,我将 127.0.0.1 作为 PURGE 的可信 URL。还有一个标准的清除配置:

vcl_recv:

....

    if (req.request == "PURGE") {

        # Allow requests from trusted IPs to purge the cache

        if (!client.ip ~ trusted) {

           error 405 "Not allowed.";

        }

        return(lookup); # @see vcl_hit;

    }

...

子 vcl_hit {

if (req.request == "PURGE") {

    purge;

    error 200 "Purged (via vcl_hit)";

}



if (!(obj.ttl > 0s)) {

    return (pass);

}



return (deliver);

}

sub vcl_miss {

if (req.request == "PURGE"){

    purge;

    error 404 "Not in Cache";

}

return (fetch);

}

现在我想通过 shellscript 使 URL 无效。

curl -X PURGE http://127.0.0.1/product-47267.html

不起作用,但是

curl -X PURGE http://www.mysite.com/product-47267.html

是否有效。这里的问题是 - 我需要在集群中的每台本地机器上失效 - 没有请求通过负载均衡器发出和返回(因为我不知道哪台机器将进行 PURGE)。

希望这是有道理的

长宽

【问题讨论】:

    标签: cluster-computing varnish


    【解决方案1】:

    您需要连接到 localhost,但 Varnish 仍然需要知道 要清除的主机

    我不确定,但请尝试以下方法:

    curl -X PURGE -H "Host: www.mysite.com" http://127.0.0.1/product-47267.html
    

    【讨论】:

      猜你喜欢
      • 2012-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-26
      • 2015-02-03
      • 2011-10-19
      • 2018-03-28
      相关资源
      最近更新 更多