当 varnish 中有多个 set cookie 请求时,如何获取 set cookie 值?

问题描述

如果我的 cookie 具有特定价值,我将尝试取消设置 cookie。 我尝试使用 beresp.http.Set-Cookie 获取值,但这似乎在响应时在 Set-Cookie 中设置了第一个值。有什么办法可以提取第二个 Set-Cookie 的值吗? 编辑

这是我的响应头

HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu)
Date: Fri,19 Feb 2021 09:47:53 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 12297
Connection: keep-alive
Cache-Control: no-cache,no-store
Pragma: no-cache
Content-Encoding: br
Set-Cookie: VarnishCustomerIsGuest=True; path=/
Set-Cookie: .Nop.Customer=62a224b9-3b5b-4e74-8200-cf341df111af; expires=Sat,19 Feb 2022 09:47:53 GMT; path=/; httponly
Set-Cookie: .Nop.TempData=; expires=Thu,01 Jan 1970 00:00:00 GMT; path=/; samesite=lax; httponly
Vary: Accept-Encoding
X-MiniProfiler-Ids: ["4f9a095d-bbd1-4ffe-81e1-31761363af25"]
X-TMP1000: VarnishCustomerIsGuest=True; path=/
X-Varnish: 163854
Age: 0
Via: 1.1 varnish (Varnish/5.2)
X-Cache: MISS
Accept-Ranges: bytes

我想要做的是在 vcl_backend_response 处获取客户 cookie。但是

beresp.http.Set-Cookie

给了我 VarnishCustomerIsGuest 的第一个 set-cookie 值,我不确定我是否可以获得客户 cookie .Nop.Customer。

我的应用程序后端总是为每个请求设置 cookie,所以我想要做的是根据 .Nop.Customer 值取消设置 cookie,以便对于某些特定客户,页面始终从 varnish 缓存中提供。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)