2012-03-28 42 views
0

我在ubuntu 11上使用清漆3.0 - 重定向正在通過expressjs處理(v2.5.8 - 正在運行node.js 0.6) - 重定向被express調用(作品之間沒有清漆),但是當在兩者之間使用清漆時,重定向到新頁面會被阻止(顯示'發現錯誤302')。html重定向在使用清漆時被阻擋

在varnish的vcl配置文件中,我試圖根據URL和Referer(在sub vcl_recv部分)傳遞(返回),但似乎配置錯​​誤(或需要添加更多配置步驟)。任何關於vcl文件變化的想法/建議都會非常受歡迎,這將允許varnish讓expressjs重定向到新頁面。

在此先感謝。

+0

我也試圖通過(返回)在sub_vcl_fetch部分。歡迎大家提出意見。 – 2012-03-28 20:31:59

+0

通過修改sub_vcl_fetch部分解決 - 我將很快在這裏發佈 - 希望它有幫助。 – 2012-03-28 21:52:09

回答

0

更改sub_vcl_fetch修復它。

我抄sub_vcl_fetch段的一部分從我下面的VCL文件:

子vcl_fetch {

# Do not cache the object if the backend application does not want us to. 
if (beresp.http.Cache-Control ~ "(no-cache|no-store|private|must-revalidate)") { 
return(pass); 
} 

# Do not cache the object if the status is not in the 200s 
if (beresp.status >= 300) { 
# Remove the Set-Cookie header 
#remove beresp.http.Set-Cookie; 
return(pass); 
} 

# 
# Everything below here should be cached 
# 
# Remove the Set-Cookie header 
####remove beresp.http.Set-Cookie; 

# Set the grace time 
set beresp.grace = 1s; 

# Static assets aren't served out of Varnish just yet, but when they are, this will 
# make sure the browser caches them for a long time. 
if (req.url ~ "\.(css|js|jpg|jpeg|gif|ico|png)\??\d*$") { 
/* Remove Expires from backend, it's not long enough */ 
unset beresp.http.expires; 

/* Set the clients TTL on this object */ 
set beresp.http.cache-control = "public, max-age=31536000"; 

/* marker for vcl_deliver to reset Age: */ 
set beresp.http.magicmarker = "1";} else { 
set beresp.http.Cache-Control = "private, max-age=0, must-revalidate"; 
set beresp.http.Pragma = "no-cache";} 

## If the request to the backend returns a code other than 200, restart the loop 
## If the number of restarts reaches the value of the parameter max_restarts, 
## the request will be error'ed. max_restarts defaults to 4. This prevents 
## an eternal loop in the event that, e.g., the object does not exist at all. 
if (beresp.status != 200 && beresp.status != 403 && beresp.status != 404) { 
restart; 
} 


if (beresp.status == 302) { 
return(deliver);} 
# return(deliver); the object 
return(deliver); 
} 

希望這有助於!