Apache 反向代理 ssl

Apache 反向代理 ssl

我设置了以下适用于 http 请求的 ReverseProxy:

NameVirtualHost *:80
<VirtualHost *:80>
ServerName sub.domain.com
ProxyRequests Off
ProxyVia Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>                              
ProxyPass / http://localhost:5010
ProxyPassReverse / http://localhost:5010/
</VirtualHost>

我的问题是,如果我的后端(位于:5010)不支持 https,我该如何处理 https 请求?

例如这样的: Client---https--->Apache----http---->Service

答案1

客户端和此 httpd 实例之间连接的传输方法完全独立于 httpd 实例和您代理的服务器之间的传输方法。这意味着,只需将代理线路(至少ProxyPassProxyPassReverse)添加到您的 HTTPS 配置中:

NameVirtualHost *:443
<VirtualHost *:443>
    ServerName sub.domain.com

    # Certificate stuff goes here...
    SSLEngine on
    SSLCertificateFile              /etc/pki/http/certs/sub.domain.com.crt
    SSLCertificateKeyFile   /etc/pki/http/private/sub.domain.com.key
    SSLCertificateChainFile /etc/pki/http/certs/interims-cert.crt
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite +EDH:HIGH:!LOW:!ADH:-MEDIUM:RC4+SHA

    ProxyRequests Off
    ProxyVia Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>                              
    ProxyPass / http://localhost:5010
    ProxyPassReverse / http://localhost:5010/
</VirtualHost>

这些SSL*指令仅用于示例目的!您应该检查如何安全地配置 HTTPS 的 httpd。

相关内容