2

下面是我的 httpd.conf 配置。我有 tomcat 服务器作为后端服务器,我使用 apache webserver 作为 tomcat 服务器的代理。

以下配置适用于所有不需要会话的网页。

当进一步调查时,我观察到 JSESSIONID 在每个 Web 请求上都在发生变化,这意味着当请求和响应通过 Apache http 服务器进行时,该 ID 不会持久化。

请注意,当我尝试将 tomcat 服务器直接暴露给 web 时,JSESSIONID 是持久的并且按预期工作。但是出于安全要求,我们只需要使用 tomcat 服务器作为后端内部服务器。

所以我不确定为什么 apache http 服务器不喜欢正确处理 JSESSIONID。请求您的帮助并指导我在我的配置中缺少什么。

注意:我们不需要任何负载均衡器设置,所以我现在不考虑 mod_proxy_balancer 模块。

<VirtualHost *:443>
ServerName www.external.com
ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
         AddOutputFilterByType SUBSTITUTE text/html
    ProxyPreserveHost off
    ProxyPass / http://localhost:8080/internal/
    ProxyPassReverse / http://localhost:8080/internal/    
    Substitute "s|http://localhost:8080/internal|https://www.external.com|i"                
    SSLProtocol all
    SSLEngine on     
    SSLCertificateFile C:/keys/site/external_cert.cer       
    SSLCertificateKeyFile C:/keys/site/www_internal_private.p12.pri.pem
    SSLCertificateChainFile C:/keys/site/Intermediate_CA.cer
</VirtualHost>

Apache Web 服务器是 Apache 2.4,tomcat 引擎是 Tomcat 8.5

4

1 回答 1

2

通过添加Header来遵循serverfault 的答案:Set-Cookie

最后,我只需要将以下行添加到我的 VirtualHost 配置中,这会将所有 cookie 路径从 /WEBAPP_NAME 更改为 / (root):

Header edit Set-Cookie "^(.*; Path=)/WEBAPP_NAME/?(.*)" $1/$2
于 2018-12-20T10:52:35.657 回答