我在Redhat上使用了Varnish 3.0.2,并且在添加vcl_hash部分后服务清漆启动失败.我做了varnishd然后使用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
cat default.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替换.
您不再使用=附加到哈希,因此:
set req.hash += req.url;
变
hash_data(req.url);