redhat – Varnish无法识别req.hash

前端之家收集整理的这篇文章主要介绍了redhat – Varnish无法识别req.hash前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Redhat上使用了Varnish 3.0.2,并且在添加vcl_hash部分后服务清漆启动失败.我做了varnishd然后使用vcl.load加载了vcl
  1. vcl.load default default.vcl
  2.  
  3. Message from VCC-compiler:
  4. Unknown variable 'req.hash'
  5. At: ('input' Line 24 Pos 9)
  6. set req.hash += req.url;
  7. --------########------------
  8.  
  9. Running VCC-compiler Failed,exit 1

cat default.vcl

  1. backend default {
  2. .host = "127.0.0.1";
  3. .port = "8080";
  4. }
  5.  
  6. sub vcl_recv {
  7. if( req.url ~ "\.(css|js|jpg|jpeg|png|swf|ico|gif|jsp)$" ) {
  8. unset req.http.cookie;
  9. }
  10. }
  11.  
  12. sub vcl_hash {
  13. set req.hash += req.url;
  14. set req.hash += req.http.host;
  15. if( req.httpCookie == "JSESSIONID" ) {
  16. set req.http.X-Varnish-Hashed-On = regsub( req.http.Cookie,"^.*?JSESSIONID=([a-zA-z0-9]{32}\.[a-zA-Z0-9]+)([\s$\n])*.*?$","\1" );
  17. set req.hash += req.http.X-Varnish-Hashed-On;
  18. }
  19. return(hash);
  20. }

可能有什么不对?

解决方法

直接引用 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替换.

您不再使用=附加到哈希,因此:

  1. set req.hash += req.url;

  1. hash_data(req.url);

猜你在找的Linux相关文章