大网数据广告活动
服务器运维问答

Configuring multiple ProxyPassReverseCookiePath in Apache HTTP

· 52CE 我爱测

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 ess…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。