redhat – Varnish无法识别req.hash

前端之家收集整理的这篇文章主要介绍了redhat – Varnish无法识别req.hash前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在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);
原文链接:https://www.f2er.com/linux/398018.html

猜你在找的Linux相关文章