7

我想在 Apache 中使用反向代理在 AWS APIGateway URL 前面。原因是由于需要静态 IP 来在严格的防火墙后面提供服务的过程,并且当前的基础架构已经安装了 mod_proxy。我希望实施的解决方案是简单地通过 mod_proxy 路由 https->https(apiGateway)。

但是.. AWS 使用 SNI,我无法让 mod_proxy 握手。

我启用了以下设置

<IfModule mod_ssl.c>
<VirtualHost *:443>
  ProxyPreserveHost On
  SSLProxyEngine On

  ProxyPass /api/1_0/ https://xxx.execute-api.eu-west-1.amazonaws.com/1_0/
  ProxyPassReverse /api/1_0/ https://xxx.execute-api.eu-west-1.amazonaws.com/1_0/

以下日志在调试模式下可用

proxy_util.c(2020): AH00942: HTTPS: has acquired connection for (xxx.execute-api.eu-west-1.amazonaws.com)
proxy_util.c(2610): AH00962: HTTPS: connection complete to 52.x.x.x:443 (xxx.execute-api.eu-west-1.amazonaws.com)
AH01964: Connection to child 0 established (server domain.com:443)
AH02003: SSL Proxy connect failed
SSL Library Error: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
AH01998: Connection closed to child 0 with abortive shutdown (server domain.com:443)
AH01997: SSL handshake failed: sending 502

如果我使用 openssl 连接,我可以演示类似的错误

openssl s_client -tls1_2 -connect xxx.execute-api.eu-west-
1.amazonaws.com:443
CONNECTED(00000003)
140735866254216:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert 
handshake failure:s3_pkt.c:1494:SSL alert number 40
140735866254216:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:s3_pkt.c:659:

为 SNI 添加 -servername 会导致有效连接

SSL handshake has read 3601 bytes and written 489 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
...

因此,我认为 mod_proxy 和 mod_ssl 没有将服务器名发送到远程 https 服务器,这可能是一个错误。

我正在运行带有服务器版本的 Ubuntu 14.04:Apache/2.4.7 (Ubuntu) 服务器构建时间:2017 年 9 月 18 日 16:37:54 OpenSSL 1.0.1f 2014 年 1 月 6 日

我也尝试将其限制SSLProxyProtocol为 TLS1_2 和密码列表,但是无论如何 sslv3 警报握手失败日志仍然存在。

有没有人遇到过这种情况并知道如何确保发送 SNI 值,或者这是 Apache 模块中的限制?

4

1 回答 1

9

这是由于ProxyPreserveHost On在配置的早期设置。代理标签下的设置ProxyPreserveHost Off按预期完成:

<Proxy "https://xxx.execute-api.eu-west-1.amazonaws.com/1_0">
    ProxyAddHeaders off
    ProxyPreserveHost off
</Proxy>

指令信息:

启用后,此选项会将 Host: 行从传入请求传递到代理主机,而不是 ProxyPass 行中指定的主机名。

此选项通常应关闭。它在特殊配置中非常有用,例如基于代理的大量名称的虚拟主机,其中原始 Host 标头需要由后端服务器评估。

于 2017-12-18T12:57:05.907 回答