会话丢失在Jetty使用Apache作为代理

我有一个基于eXist-db的应用程序。 这基本上是一个使用Jetty的Java Web应用程序。 它运行在Apache代理之后的远程Linux服务器上。

我使用下面的Apacheconfiguration:

ServerName domain.com ProxyRequests off ProxyPass /myapp http://localhost:8899/exist/apps/myapp ProxyPassReverse /myapp http://localhost:8899/exist/apps/myapp 

一切工作正常,除了会议。 每次请求会话都会被更新。 这意味着请求Cookie头不包含JSESSIONID但响应Set-Cookie头是类似JSESSIONID=oryq5odyt3f79xxax25n7x0h;Path=/exist 。 此外,我检查确认会话是每次新的应用程序中的会话ID。

我已经尝试了三种testing场景:

testing场景A:

  • 客户端:Windows 7,Google Chrome
  • 服务器:Ubuntu 12.04.4 LTS(GNU / Linux 3.11.0-26-generic x86_64),代理Apache / 2.4.9

testing场景B:

  • 客户端:Windows 7,Google Chrome
  • 服务器:CentOS 6.6版(最终版),Apache / 2.2.15代理版

testing场景C(本地):

  • 客户端:Windows 7,Google Chrome
  • 服务器(相同的笔记本电脑):Windows 7,没有代理

问题出现在A和B两种情况下,但不在C中

任何想法如何使会议工作?

以下Apacheconfiguration解决了这个问题:

 ServerName domain.com ProxyRequests off ProxyPass /myapp http://localhost:8899/exist/apps/myapp ProxyPassReverse /myapp http://localhost:8899/exist/apps/myapp ProxyPassReverseCookiePath /exist / 

它将cookies从/exist的path更改为/ ,以便将会话正确映射到path。

在某些情况下,可能还需要使用以下指令来更改Cookie中的域(但在我的情况下不需要):

 ProxyPassReverseCookieDomain localhost domain.com 

我发现更多的细节在stackoverflow 。