【问题标题】:Apache ProxyPass HTTPS and remote server with SNIApache ProxyPass HTTPS 和带有 SNI 的远程服务器
【发布时间】:2018-05-22 22:39:59
【问题描述】:

我想在 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】:

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

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

    指令信息:

    启用后,此选项将从传入的 Host: 行 向代理主机发出请求,而不是在 ProxyPass 线。

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

    【讨论】:

      猜你喜欢
      • 2016-04-24
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 2018-08-04
      • 2023-03-06
      • 2012-07-27
      • 2017-06-16
      • 2011-01-27
      相关资源
      最近更新 更多