2012-11-13 94 views
2

我有一個網站www.mysite.com運行在負載平衡器後面。負載均衡器集羣中有兩臺服務器。每個運行Varnish 3.0和Apache/PHP(我知道清漆可以爲我平衡 - 但我們有一個不同的LB技術的偏好)。清漆3.0.3羣集

時不時我需要清除的URL或兩個...

在我的VCL我有127.0.0.1作爲清除受信任的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); 

}

子vcl_miss {

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

    purge; 

    error 404 "Not in Cache"; 

} 

return (fetch); 

}

現在從一個shell腳本我想使一個URL失效。

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

犯規工作,但

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

是否工作。這裏的問題是 - 我需要在集羣中的每臺本地計算機上使其無效 - 沒有請求通過負載平衡器返回並返回(因爲我不知道哪臺計算機將採用PURGE)。

希望這是有道理

LW

回答

3

您需要連接到本地主機光油仍然需要知道哪些主機要清除。

我不知道,但嘗試類似如下:

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

偉大的 - 的作品 - 感謝這麼多。 – user1614933