2017-04-06 25 views
0

我用清漆4,PHP-FPM 7,nginx的,CentOS的7光油4 ESI:bereq.url不讀ESI SRC標籤內的網址

我varnish.params:

DAEMON_OPTS="-a :80 -T 127.0.0.1:6082 
      -f /etc/varnish/default.vcl 
      -S /etc/varnish/secret 
      -s malloc,1g 
      -p feature=+esi_disable_xml_check,+esi_ignore_other_elements 
      -p cli_buffer=16384 
      -p vcc_allow_inline_c=on" 

我default.vcl:

if (bereq.url ~ "^.*(\/**esi**\/)+.*$") { 
    set beresp.do_esi = true; 
    set beresp.ttl = 0s; 
} else { 
    set beresp.ttl = 3600s; 
} 

我的問題是,當我使用它是通過訪問觸發VCL代碼說:http://localhost/lab/varnish

其中渲染:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
</head> 
<body> 
    <esi:include src="http://localhost/lab/esi/body"/> 
</body> 
</html> 

光油沒有讀取ESI標籤中的URL src,所以它只是渲染一個空的主體。

但是,當我使用此代碼:

if (bereq.url ~ "^.*(\/**lab**\/)+.*$") { 
    set beresp.do_esi = true; 
    set beresp.ttl = 0s; 
} else { 
    set beresp.ttl = 3600s; 
} 

光油成功地使這是由生產ESI標籤中的內容: http://localhost/lab/esi/body

如何使光油觸發ESI片段渲染基於識別ESI「src」標籤中的內容?

我試過設置代理能力和使用代理控制檢查,它也不適用於我。我正在用盡線索..

回答

0

我不認爲你可以。

如果將beresp.do_esi設置爲true,Varnish將解析後端響應,並將其每個esi:include標記替換爲其源內容。

如果你沒有清漆不會解析beresp並按原樣將其提供給客戶。

順便說一句你爲什麼要部分取代esi標籤?

+0

我希望varnish使用已經緩存的內容向客戶端提供服務,並且僅從ESI標籤內的源代碼中排除(請求後端)內容。是否可以這樣做? –