我正在使用 Apache Portable Runtime 在 Tomcat7 上运行应用程序,我购买了 SSL 证书并正确配置了它 - 当我尝试通过 ip:port 组合连接时,它连接正常但警告我证书颁发给域名,而不是 IP。
我使用的 VPS 没有 SELinux(并且存在安装问题),这是 AFAIK 在 apache 中配置 SSL 所必需的,所以我只想将请求路由到 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)
在 Chromium 中:
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=8080< 的纯文本 HTTP 连接器
和 address=127.0.0.1
,这样任何外人都无法访问它。
更好的是,Tomcat 中没有任何 HTTP 连接器,只有 AJP 连接器,address=127.0.0.1
,并在 Apache 中使用 mod_proxy_ajp。
关于ssl - 配置 apache 服务器代理 SSL 连接时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18107358/