我在 Redhat 上安装了 Varnish 3.0.2,并且在添加 vcl_hash 部分后服务 varnish 启动失败。我做了清漆,然后使用 vcl.load 加载了 vcl
vcl.load default default.vcl
Message from VCC-compiler:
Unknown variable 'req.hash'
At: ('input' Line 24 Pos 9)
set req.hash += req.url;
--------########------------
Running VCC-compiler failed, exit 1
猫默认.vcl
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if( req.url ~ "\.(css|js|jpg|jpeg|png|swf|ico|gif|jsp)$" ) {
unset req.http.cookie;
}
}
sub vcl_hash {
set req.hash += req.url;
set req.hash += req.http.host;
if( req.httpCookie == "JSESSIONID" ) {
set req.http.X-Varnish-Hashed-On = regsub( req.http.Cookie, "^.*?JSESSIONID=([a-zA-z0-9]{32}\.[a-zA-Z0-9]+)([\s$\n])*.*?$", "\1" );
set req.hash += req.http.X-Varnish-Hashed-On;
}
return(hash);
}
有什么问题?
直接引用自https://www.varnish-cache.org/docs/3.0/installation/upgrade.html#req-hash-is-replaced-with-hash-data
在 Varnish 3.x 中,
req.hash
被替换为hash_data
.您不再使用 += 附加到哈希,因此:
变成