问题原文
原帖链接 · PentaKon · CC BY-SA 4.0
I have a server with an Apache reverse proxy in front. The server machine contains 2 web applications running under:
- localhost:8000/app and exposed as my.url.com/app1
- localhost:8001/app and exposed as my.url.com/app2
They are essentially different versions of the webapp and we want them both up. Both webapps create a cookie like so:
Set-Cookie: sessionid=as7d86fa98sg67; Path=/app; HttpOnly
Note that there is no Domain property on the cookie header.
I have added 2 different ProxyPassReverseCookiePath directives like so:
- ProxyPassReverseCookiePath /app /app1
- ProxyPassReverseCookiePath /app /app2
The goal is that each webapp will have its Path=/app transformed to the appropriate context. However the ProxyPassReverseCookiePath directives seem to override one another and don't have awareness of the webapp they run for.
TL;DR:
ProxyPass /app1/ http://localhost:8000/app/
ProxyPassReverse /app1/ http://localhost:8000/app/
ProxyPassReverseCookiePath /app /app1
ProxyPass /app2/ http://localhost:8001/app/
ProxyPassReverse /app2/ http://localhost:8001/app/
ProxyPassReverseCookiePath /app /app2
This configurations works, except for the cookie path property. For both cases it gets replaced with Path=/app1/ whereas I'd like it to be specific to each app that handles the request.
已采纳解答
原帖链接 · PentaKon · CC BY-SA 4.0
After searching around the solution is to group the directives under a <Location> tag:
<Location /app1>
ProxyPassReverseCookiePath /app /app1
</Location>
<Location /app2>
ProxyPassReverseCookiePath /app /app2
</Location>
This way Apache knows to properly apply each directive depending on the origin of the response.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
