首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编辑cookie SameSite属性

编辑cookie SameSite属性
EN

Stack Overflow用户
提问于 2021-09-29 18:09:17
回答 1查看 1.5K关注 0票数 0

我有一个Nginx1.11.10,并试图操作cookie的SameSite属性。看来NGINX有个选择

proxy_cookie_flags

然而,这只能在NGINX 1.19.3及以上版本中找到。

如何在1.11.10中实现类似的行为来操作所有cookie或特定cookie?

这是我们在Apache中的类似配置。

代码语言:javascript
复制
# SameSite Cookie Configuration http://publib.boulder.ibm.com/httpserv/ihsdiag/_static/samesite-global.conf
# 1. Add SameSite=Strict and Secure if no SameSite found.
Header always edit Set-Cookie "^(?!.*(\s+|;)(?i)SameSite=)(.*)" "$0; SameSite=Strict; Secure" env=!SAMESITE_SKIP
Header onsuccess edit Set-Cookie "^(?!.*(\s+|;)(?i)SameSite=)(.*)" "$0; SameSite=Strict; Secure" env=!SAMESITE_SKIP
# 2. Remove duplicate SECURE flag (this keeps the above regex simpler)
Header always edit Set-Cookie "(.*(\s+|;)(?i)Secure(\s+|;).*) Secure$" "$1" env=!SAMESITE_SKIP
Header onsuccess edit Set-Cookie "(.*(\s+|;)(?i)Secure(\s+|;).*) Secure$" "$1" env=!SAMESITE_SKIP
# Why the duplication?  always is not a superset of onsuccess the way it should be.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-07 20:04:14

首先(我知道你知道这一点),请尝试将NGINX更新到最新版本。你为什么要用这样的旧版本?

然而,proxy_cookie_flags指令取代了这里可用的第三方模块:https://github.com/AirisX/nginx_cookie_flag_module

如果无法更新,则可以加载此动态模块并使其正常工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69381460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档