在 Apache Loadbalancer 和后端之间使用 Https

use*_*383 35 reverse-proxy mod-ssl apache-2.2 apache-2.4

我在 2 个 apache 服务器前使用配置为负载均衡器的 apache (2.4) 服务器。当我在负载均衡器和后端之间使用 http 连接时它工作正常,但是使用 https 不起作用。负载均衡器的配置:

SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
<Proxy balancer://testcluster>
  BalancerMember https://[Backend1]:443/test
  BalancerMember https://[Backend2]:443/test
</Proxy>
ProxyPass /test balancer://testcluster
Run Code Online (Sandbox Code Playgroud)

后端目前只有自签名证书,这就是禁用证书验证的原因。

负载均衡器上的错误日志包含以下内容:

[proxy:error] [pid 31202:tid 140325875570432] (502)Unknown error 502: [client ...] AH01084: pass request body failed to [Backend1]:443 ([Backend1])
[proxy:error] [pid 31202:tid 140325875570432] [client ...] AH00898: Error during SSL Handshake with remote server returned by /test/test.jsp
[proxy_http:error] [pid 31202:tid 140325875570432] [client ...] AH01097: pass request body failed to [Backend1]:443 ([Backend1]) from [...] ()
Run Code Online (Sandbox Code Playgroud)

浏览器中的错误页面包含:

Proxy Error

The proxy server could not handle the request GET /test/test.jsp.
Reason: Error during SSL Handshake with remote server
Run Code Online (Sandbox Code Playgroud)

正如我上面已经说过的,将配置更改为 http 协议并且端口 80 有效。客户端和负载均衡器之间的 https 连接也可以工作,因此负载均衡器的 ssl 模块似乎设置正确。通过 https 直接连接到后端也不会产生任何错误。

在此先感谢您的时间


编辑:我想通了,问题是我的证书通用名称与服务器名称不匹配。我认为SSLProxyVerify none会导致这种不匹配被忽略,但事实并非如此。在 apache 2.4.5 之前,可以使用SSLProxyCheckPeerCN off禁用此检查但在更高版本上(我使用的是 2.4.7)还需要指定SSLProxyCheckPeerName off

sslproxycheckpeername 的 Apache 文档

工作配置如下所示:

SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off

<Proxy balancer://testcluster>
  BalancerMember https://[backend1]:443/test
  BalancerMember https://[backend1]:443/test
</Proxy>
ProxyPass /test balancer://testcluster
Run Code Online (Sandbox Code Playgroud)

不幸的是,由于缺乏声誉,我无法回答我自己的问题,所以我编辑了我的问题,希望这对遇到类似问题的人有所帮助

ETL*_*ETL 18

问题原来是证书通用名称与服务器名称不匹配。

在 Apache 2.4.5 之前,可以禁用此检查,SSLProxyCheckPeerCN off但在更高版本(例如 2.4.7)上SSLProxyCheckPeerName off还需要指定。

Apache 文档 SSLProxyCheckPeerName

工作配置如下所示:

SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off

<Proxy balancer://testcluster>
  BalancerMember https://[backend1]:443/test
  BalancerMember https://[backend1]:443/test
</Proxy>
ProxyPass /test balancer://testcluster
Run Code Online (Sandbox Code Playgroud)

您可以使用以下命令检查您拥有的 Apache 版本

apachectrl -V
Run Code Online (Sandbox Code Playgroud)