麻烦configurationApache服务器代理SSL连接

我正在Apache Portable Runtime上运行Tomcat7上的应用程序,我购买了SSL证书并正确configuration了它 – 当我尝试通过ip:port组合连接时,它连接正常,但是警告我证书颁发给了域名,不是IP。

我正在使用的VPS没有安装SELinux(有安装问题),这是AFAIK要求在Apache中configurationSSL,所以我只想将请求路由到Tomcat,它在它的末尾。

我configuration了Apache来代理连接,首先使用端口80,完美的工作:

NameVirtualHost www.mysite.com:80 <VirtualHost www.mysite.com:80> ProxyPreserveHost On ProxyRequests Off ServerName http://www.mysite.com ServerAlias http://www.mysite.com ProxyPass / http://localhost:8180/MYSITE/ ProxyPassReverse / http://localhost:8180/MYSITE/ ProxyPassReverseCookiePath /MYSITE/ / </VirtualHost> 

然后用不想工作的SSL端口出于某种原因:

 NameVirtualHost www.mysite.com:443 <VirtualHost www.mysite.com:443> SSLProxyEngine On ProxyPreserveHost On ProxyRequests Off ServerName https://www.mysite.com ServerAlias https://www.mysite.com ProxyPass / https://localhost:8443/MYSITE/ ProxyPassReverse / https://localhost:8443/MYSITE/ ProxyPassReverseCookiePath /MYSITE/ / CacheDisable * </VirtualHost> 

编辑 :我添加了

 RequestHeader set Front-End-Https "On" 

指令到VirtualHost www.mysite.com:443,按照: http : //www.gossamer-threads.com/lists/apache/users/396577

这是在Tomcat的server.xml中configuration的Tomcat APR连接器 –

 <Connector port="8443" maxHttpHeaderSize="16500" maxThreads="150" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" SSLEnabled="true" SSLCertificateFile="x509-cert-path" SSLCertificateKeyFile="key-file-path" /> 

没有错误/警告启用虚拟主机和重新启动Apache。 当我尝试https时,这就是我在FFox中​​看到的:

 SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long) 

在铬:

 Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error. 

Apache的error.log显示了这个警告信息:

 [warn] [client 216.58.38.90] proxy: no HTTP 0.9 request (with no host line) on incoming request and preserve host set forcing hostname to be www.mysite.com for uri / 

我花了好几天的时间来尝试configuration它,如果有人解释了发生了什么以及如何解决这个问题,我将非常感激。

非常感谢。 胜利者。

您遇到的错误可能是由于您的客户端(Firefox)尝试使用SSL,但您的Apache虚拟主机没有启用SSL。

为了让您的客户能够通过SSL与您的前端代理进行通信,您需要在前端而不是在Tomcat上进行SSL。 通过在Apache和Tomcat之间使用SSL,您绝对没有什么收获。

在你的<VirtualHost>块中,你至less需要:

 SSLEngine On SSLCertificateFile ... SSLCertificateKeyFile ... 

此外,请注意htat SELinux与SSL完全无关,除非configuration错误的SELinux环境可能会阻止Apache读取必要的SSL证书。

如果你没有使用Apache作为简单代理之外的其他任何东西,而且你对Apacheconfiguration感到不适应,那么理论上你就可以摆脱它,只要让Tomcat监听端口443(通过修改相应的Connector块)即可。