负载均衡器(http / https)后面的Apache(http) – redirect不保留https

我有两种configuration(开发和分段) – 具有(假定)相同的configuration:一组仅包含HTTP的Apache实例,位于Citrix负载均衡器之后,允许HTTP和HTTPS连接。

Apache VirtualHost定义包含以下指令:

RedirectMatch permanent /something/endpoint(.*)$ /something/otherendpoint$1 SSLProxyEngine On ProxyPass /something/endpoint ! ProxyPass /something https://192.168.1.100:6443/something <Location /something> ProxyPassReverse https://192.168.1.100:6443/something </Location> 

所以,我想代理任何请求/something到不同的后端HTTPS服务器,除了/something/endpoint ,我需要redirect

现在,在我的开发环境中一切正常。 我可以访问http://hostname/something/endpoint ,它会将我redirect到http://hostname/something/otherendpoint 。 同样,我可以访问https://hostname/something/endpoint ,它会将我redirect到https://hostname/something/otherendpoint

但是在暂存环境中, http://hostname/something/endpointhttps://hostname/something/endpointredirect到http://hostname/something/otherendpoint – 它不保留HTTPS。

我一直在拉我的头发,试图找出两种configuration之间的区别。 必须有东西导致Apache不尊重访问协议,但我无法隔离它。 在两种环境中,HTTP响应标头都是相同的,除了指定http而不是https的redirectLocation标头。

任何关于什么configuration差异可能会导致这种想法?

请记住,永久性redirect被网页浏览器caching,您需要在configuration中的每个testing/修改后手动清除浏览器caching,或在“隐身”/“匿名”浏览器窗口中进行testing。

Apache httpd如何合并configuration指令可能有点棘手。 你正在使用的语法似乎有点不一致,可能是你的问题的原因:

 ProxyPass /something https://192.168.1.100:6443/something <Location /something> ProxyPassReverse https://192.168.1.100:6443/something </Location> 

为了清晰起见,请使用

 ProxyPass /something/endpoint ! ProxyPass /something https://192.168.1.100:6443/something ProxyPassReverse /something https://192.168.1.100:6443/something 

或者将所有内容都放在Location指令中:

 <Location /something> ProxyPass https://192.168.1.100:6443/something ProxyPassReverse https://192.168.1.100:6443/something </Location> <Location /something/endpoint> ProxyPass "!" Redirect permanent /something/otherendpoint </Location>