我有一个Nginx1.11.10,并试图操作cookie的SameSite属性。看来NGINX有个选择
proxy_cookie_flags
然而,这只能在NGINX 1.19.3及以上版本中找到。
如何在1.11.10中实现类似的行为来操作所有cookie或特定cookie?
这是我们在Apache中的类似配置。
# 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.发布于 2021-10-07 20:04:14
首先(我知道你知道这一点),请尝试将NGINX更新到最新版本。你为什么要用这样的旧版本?
然而,proxy_cookie_flags指令取代了这里可用的第三方模块:https://github.com/AirisX/nginx_cookie_flag_module
如果无法更新,则可以加载此动态模块并使其正常工作。
https://stackoverflow.com/questions/69381460
复制相似问题