我想在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不会将Servername发送到远程HTTPS服务器,并且可能是一个错误。
我正在运行Ubuntu 14.04服务器版本:Apache/2.4.7(Ubuntu)服务器建造:2017年9月18日16:37:54OpenSSL 1.0.1F 2014年1月6日
我试图将SSLProxyProtocol
限制为TLS1_2和密码列表,但是SSLV3警报握手故障日志仍然存在。
有没有人遇到此问题并知道如何确保SNI值是发送的,还是Apache模块中的限制?
这是由于ProxyPreserveHost On
在配置中的早期设置。在代理标签下设置ProxyPreserveHost Off
按预期完成:
<Proxy "https://xxx.execute-api.eu-west-1.amazonaws.com/1_0">
ProxyAddHeaders off
ProxyPreserveHost off
</Proxy>
有关指令的信息:
启用后,此选项将通过host:incoming ost the host:line 请求对代理主机,而不是在 proxypass线。
通常应关闭此选项。它大多有用 特殊配置,例如代理质量名称的虚拟托管, 原始主机标头需要由后端评估 服务器。
上面的答案对我们有所帮助。为了"谷歌搜索"我也想添加以下情况:我们在我们的一项服务的前面使用云WAF。另一项服务需要将特定的查询转发到此主机并通过WAF。工作配置看起来像:
<Proxy "balancer://qwertz">
ProxyPreserveHost off
BalancerMember "https://somehost.somewhere.de:443"
</Proxy>
ProxyPass "/special/webservices/" "balancer://qwertz/special/webservices/"
ProxyPassReverse "/special/webservices/" "balancer://qwertz/special/webservices/"
Apache被配置为反向代理,并在Docker容器中运行。请注意,平衡器只有一个主机,因此未完成平衡。在此答案之前,我们得到了SSL erros,例如:
Error during SSL Handshake with remote server returned by...
pass request body failed to...
或
server certificate does NOT include an ID which matches the server name
像AWS一样,云WAF也需要SNI。希望这个帖子能使这个答案更加可见(或可以找到)。