acl - Haproxy 设置相同会话 cookie 依赖于用户代理
问题描述
在 haproxy 中,我需要能够根据用户代理为 cookie 设置相同的站点,因为某些旧版本的 chrome 不支持此标志,然后我需要删除。
我已经尝试了以下配置,但它并不想工作:
acl old_chrome capture.req.hdr(User-Agent) ^.+Chrome\/(((5[1-9])|6[0-6]))\..+$
http-response replace-header Set-Cookie: SERVERID; SameSite=None if !old_chrome
有什么建议吗?
解决方案
我已经使它与以下配置一起工作:
declare capture request len 40000
http-request capture req.fhdr(User-Agent) len 64
http-response replace-header Set-Cookie (JSESSIONID=[^;]*);(.*) \1;\ Path=/;\ Secure;\ HttpOnly;\ SameSite=None if !{ capture.req.hdr(1) -i -m reg ^.+Chrome\/(((5[1-9])|6[0-6]))\..+$ }
推荐阅读
- xaml - 当 XAML 中的静态资源采用格式时,如何将文本添加到 StringFormat
- python - Pycaret - 卡在 Setup()
- javascript - Rollup Vue2 - 构建失败
- php - 如果 id 与第二个数组匹配,则遍历 2 个数组并从第一个数组中检索值。(PHP)
- python - 在 Visual Studio Code 中运行代码时是否使用了不同版本的 python?
- python - 将大于字符“>”作为命令行参数传递给 Python 脚本
- c++ - 如何将 void 函数指针作为参数传递
- javascript - 如何显示更新 PWA 的消息?
- python - ValueError:检查输入时出错:预期的dense_input有2维,但得到的数组形状为(1、1、15)
- delphi - Delphi(2006):如何按换行符拆分并同时中断