具有SNI的Apache ProxyPass HTTPS和远程服务器

问题描述 投票:1回答:1

我想在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模块中的限制?

apache mod-proxy mod-ssl
1个回答
3
投票

这是因为ProxyPreserveHost On在配置的早期设置。在代理标记下设置ProxyPreserveHost Off按预期完成:

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

有关指令的信息:

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

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

© www.soinside.com 2019 - 2024. All rights reserved.