配置 Apache 使用外部代理进行 HTTPS 连接

tom*_*lec 7 ssl proxy apache-2.2

我试图让我的 Apache 对 HTTPS 请求使用外部代理:

Listen 80
Listen 443
..
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
..
SSLProxyEngine On
SSLProxyVerify none
SSLCACertificateFile conf/cert/curl-ca-bundle.cert

ProxyRemote http://*.externaldomain.com:80 http://external.proxy.com:8585
ProxyRemote http://*.externaldomain.com:443 https://external.proxy.com:8585
ProxyPass    /sub      https://sub.externaldomain.com/
Run Code Online (Sandbox Code Playgroud)

但是对http://localhost/sub/something 的请求 返回 503 并给出:

[Fri Apr 15 17:38:15 2011] [error] (OS 10060)A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.  : proxy: HTTPS: attempt to connect to 11.11.11.111:443 (sub.domain.com) failed
Run Code Online (Sandbox Code Playgroud)

有什么奇怪的

curl -x 11.11.11.111:8585 https://sub.externaldomain.com/something
Run Code Online (Sandbox Code Playgroud)

作品。

如何让 Apache 为 https 请求使用外部代理?

tom*_*lec 1

我终于让它工作了:)问题出在(RTFM)

“match 是远程服务器支持的 URL 方案的名称,或者应使用远程服务器的部分 URL,或者 * 表示应针对所有请求联系服务器。remote-server 是部分 URL对于远程服务器。”

所以解决办法很简单,使用ProxyRemoteMatch

ProxyRemoteMatch externaldomain\.com http://external.proxy.com:8585
Run Code Online (Sandbox Code Playgroud)