【问题标题】:Varnish remove from hash_data从 hash_data 中移除清漆
【发布时间】:2017-02-14 07:06:32
【问题描述】:

是否可以从已经通过先前的 hash_data() 调用添加的哈希中删除项目?

我有一个 varnish 3 服务器在标准 LAMP 堆栈前面运行,并根据 varnish 文档使用 Maxmind geoip VMOD,除了包含一个我无权编辑的 VCL 文件,它基本上具有:

sub vcl_hash {
  if (req.http.X-Geo-Country) {
    hash_data(req.http.X-Geo-Country);
  }
}

我知道我可以多次调用 vcl_hash 并且它们按顺序连接,所以我想做的是如下所示(un_hash_data 不存在),以便基于主页哈希在 req.http.X-Geo-Country 上。 有没有类似 un_hash_data() 的东西可以从哈希中删除它。

sub vcl_hash {
  if (req.url == "/") {
    un_hash_data(req.http.X-Geo-Country);
  }
}

【问题讨论】:

    标签: varnish-vcl


    【解决方案1】:

    在 vcl_recv 中,您可以为与主页不匹配的页面/请求取消设置 req.http.X-Geo-Country。如果 X-Geo-Country 未设置/为空 - 将生成相同的哈希 :)

    【讨论】:

      猜你喜欢
      • 2017-04-25
      • 2016-01-04
      • 2014-10-17
      • 2014-01-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2018-01-05
      • 2012-08-07
      相关资源
      最近更新 更多