tomcat 7.0.23 无法从 apache 服务器建立 SSL 连接。

标签 tomcat ssl proxy cluster-computing

您好,我有以下 server.xml 设置。

Server port="7005" shutdown="SHUTDOWN-TOMCAT-C">
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
    <Listener className="org.apache.catalina.core.JasperListener" />
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
   <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

    <Service name="Catalina">
        <Connector port="7070" protocol="org.apache.coyote.http11.Http11NioProtocol" 
                   connectionTimeout="20000" 
                   redirectPort="7443" />
        <Connector port="7443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" 
                   SSLEnabled="true" scheme="https" secure="true" clientAuth="want" sslProtocol="TLS" 
                   keystoreFile="${key.path}\compresskey.bin" keystorePass="${keystorePass}" 
                   compression="on" compressableMimeType="text/html,text/xml,text/plain,text/javascript,text/css"/>
        <Connector port="7009" protocol="org.apache.coyote.ajp.AjpProtocol" redirectPort="7443" enableLookups="false"  />

        <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat-c">
            <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                     channelSendOptions="10">
                <Manager className="org.apache.catalina.ha.session.BackupManager"
                       expireSessionsOnShutdown="false"
                       notifyListenersOnReplication="true"
                       mapSendOptions="10"/>
                <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                         filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
                <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
            </Cluster>

<Context path="/mvc2_app1"
                      docBase="${user.home}\webapps\mvc2_app1"
                      cookies="true"
                      override="true"
                      reloadable="false"
                      swallowOutput="true"
                      distributable="true"
                      logEffectiveWebXml="true"
                      xmlNamespaceAware="false"
                      xmlValidation="false"
                      className="org.apache.catalina.core.StandardContext">
</context>
</service>

</host>

我的 worker.properties

worker.tomcat-c.port=7009
worker.tomcat-c.host=localhost
worker.tomcat-c.type=ajp13
worker.tomcat-c.lbfactor=1

这是我的 httpd.conf 设置。

<VirtualHost ${host}:443> 
SSLEngine On ServerName ${host} 
ErrorLog "logs/error.log" 
LogLevel warn 
SSLCertificateFile conf/ssl/server.crt 
SSLCertificateKeyFile conf/ssl/server.key 
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown 
SSLProxyEngine On 
ServerAdmin local@admin.com 
RewriteEngine On 

ProxyPreserveHost On #applications on 5443 
ProxyPass /mvc2_app1 https://${host}:7443/mvc2_app1 

ProxyPassReverse /mvc2_app1 https://${host}:7443/mvc2_app1 
</virtual_host>

当我尝试连接到 https://localhost/mvc2_app1 时,我收到错误 500 代理错误。

这是我的错误日志 代理:在与/mvc2_app1 返回的远程服务器进行 SSL 握手期间出错 代理:从 ${local ip}

向 ${local ip}:7443 (${host}) 传递请求正文失败

有什么建议或技巧吗?

谢谢。

-- 更新-- 我可以毫无问题地连接到 apache 服务器。 https://localhost有效但https://localhost/mvc2_app1才不是。

所以我的tomcat日志是这样的。

Dec 25, 2011 10:21:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-7070"]
Dec 25, 2011 10:21:57 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Dec 25, 2011 10:21:57 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-7443"]
Dec 25, 2011 10:21:58 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Dec 25, 2011 10:21:58 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-7009"]
    Dec 25, 2011 10:21:58 PM org.apache.catalina.tribes.membership.McastServiceImpl setupSocket
    INFO: Setting cluster mcast soTimeout to 500
    Dec 25, 2011 10:21:58 PM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
    INFO: Sleeping for 1000 milliseconds to establish cluster membership, start level:4
    Dec 25, 2011 10:21:59 PM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
    INFO: Done sleeping, membership established, start level:4
    Dec 25, 2011 10:21:59 PM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
    INFO: Sleeping for 1000 milliseconds to establish cluster membership, start level:8
    Dec 25, 2011 10:22:00 PM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
    INFO: Done sleeping, membership established, start level:8
    Dec 25, 2011 10:22:00 PM org.apache.catalina.tribes.tipis.AbstractReplicatedMap init
    INFO: Initializing AbstractReplicatedMap with context name:/mvc2_app1
    Dec 25, 2011 10:22:00 PM org.apache.catalina.tribes.tipis.AbstractReplicatedMap init
    INFO: Initializing AbstractReplicatedMap with context name:/mvc2_app2

最佳答案

你混淆了 mod_jkmod_proxy

worker.properties 参数用于 mod_jk,它使用 AJP,但它们不被 mod_proxy_ajp 使用(现在推荐通过 mod_jk 进行 AJP 连接)。

您的 ProxyPassReverse 配置使用 mod_proxy_http(https:// URL,而不是 ajp://) ,而不是 mod_jkmod_proxy_ajp。为此,在 Tomcat 上启用 AJP 没有多大意义。

您可能不需要在 Apache Httpd 服务器和 Apache Tomcat 服务器(从本地主机到本地主机)之间使用 HTTPS。但是,如果您觉得需要,请使用 SSLProxy* 指令,如 mod_proxy 顶部所述文档。

关于tomcat 7.0.23 无法从 apache 服务器建立 SSL 连接。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8469628/

相关文章:

Apache JMeter 记录问题 403 Apache Tomcat

tomcat - 我可以在 servlet 映射中组合这些 url 模式吗?

ssl - HttpWebRequest 结果为 "The request was aborted: Could not create SSL/TLS secure channel"

amazon-web-services - 将证书上传到 IAM

c# - 如何使用 InternetSetOption?

ssl - HTTPS Web(仅)代理

git - Perl 脚本在 tom cat 6.0 上变慢并产生服务超时

java - 在 spring web 应用程序中创建数据源的正确方法是什么?

java - 在 Eclipse 中,当所有三个项目都需要 servlet-api.jar 时,如何让 tomcat 运行两个连接的项目?

javascript - 有没有办法在没有 SSL 证书的情况下清除 HSTS?