Apache如何使用&QUOT;报头组设置Cookie过期=&LT;日期和GT;&QUOT;动态 [英] apache How to use "Header set Set-Cookie expires=<date>" dynamically
问题描述
我使用Apache作为负载均衡和反向代理。
对于会话粘性我创建与节点的路径的cookie。
I am using apache as a load balancer and reverse proxy. For session stickiness I am creating a cookie with the route of the node.
Header set Set-Cookie "h=.%{BALANCER_WORKER_ROUTE}e; path=/; domain=.domain.com" env=BALANCER_ROUTE_CHANGED
如何设置终止
在Cookie值从当请求进来X分钟?
How do I set the expires
value in the cookie to be X minutes from when the request comes in?
有关 mod_headers中的文档甚至不包括设定饼干
详细所以在动态语法没有资料没有用于终止
。
The documentation for mod_headers Doesn't even cover Set-Cookie
in detail so there is no info there on a dynamic syntax to use for expires
.
我尝试设置最大年龄
,但可惜的的最大年龄不与IE 11 的工作和大量的客户使用它。
I tried setting the max-age
but unfortunatelly max-age doesn't work with IE 11 and lots of our customers use it.
有关 mod_rewrite的饼干该文档也包括如何在cookie中设置了一辈子这样我就可以得到它使用这个丑陋的mod_rewrite破解工作,但我不得不这样做每条路线的一个规则,因为它没有里面我&LT工作;代理平衡器:// my_cluster&GT;
部分:
The docs for mod_rewrite cookie do cover how to set a lifetime in the cookie so I can get it to work using this ugly mod_rewrite hack but I had to do one rule per route since it didn't work inside my <Proxy balancer://my_cluster>
section:
RewriteCond %{HTTP_COOKIE} h=.1 [NC]
RewriteRule . - [CO=h:.1:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.2 [NC]
RewriteRule . - [CO=h:.2:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.3 [NC]
RewriteRule . - [CO=h:.3:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.4 [NC]
RewriteRule . - [CO=h:.4:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.5 [NC]
RewriteRule . - [CO=h:.5:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.6 [NC]
RewriteRule . - [CO=h:.6:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.7 [NC]
RewriteRule . - [CO=h:.7:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.8 [NC]
RewriteRule . - [CO=h:.8:.domain.com:30:/]
有关如何使用报头组设置Cookie
完成任何想法?谢谢!
推荐答案
也许你可以让你的想法与通用规则
Maybe you could keep your idea with a generic rule
RewriteCond %{HTTP_COOKIE} h=\.([1-8]) [NC]
RewriteRule . - [CO=h:.%1:.domain.com:30:/]
这篇关于Apache如何使用&QUOT;报头组设置Cookie过期=&LT;日期和GT;&QUOT;动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!