将apache服务器配置为代理SSL连接时出现问题



我正在使用Apache Portable Runtime在Tomcat7上运行一个应用程序,我购买了SSL证书并正确配置了它-当我尝试通过ip:port组合进行连接时,它连接良好,但警告我证书是颁发给域名的,而不是颁发给ip的。

我所在的VPS没有SELinux(安装时出现问题),这是在apache中配置SSL所需的AFAIK,所以我只想将请求路由到Tomcat,Tomcat会自行完成。

我配置了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-中配置的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 /

我花了好几天的时间试图配置它,如果有人解释发生了什么以及如何修复它,我将不胜感激

非常感谢。维克多。

Tomcat中不需要8443 HTTPS连接器。Apache HTTPD应该终止SSL连接,并通过ProxyPass / http://localhost:8080/MYSITE/.向Tomcat发出明文。您只需要一个带有port=8080address=127.0.0.1的明文HTTP连接器,这样外部人员就无法访问它。

更好的是,Tomcat中没有任何HTTP连接器,只有AJP连接器address=127.0.0.1,并且在Apache中使用mod_proxy_AJP。

最新更新