通过 mod_jk 在 apache 后面的 tomcat 上运行多个域时遇到问题

通过 mod_jk 在 apache 后面的 tomcat 上运行多个域时遇到问题

我在 apache2 后面设置带有 2 个虚拟主机的 tomcat6 时遇到了麻烦。

如果我在 tomcat 中只定义了一个主机和一个 jk worker,则一切都正常工作。一旦我定义另一个 jk worker 和相应的 tomcat 主机,我就会在 jk.log 中收到此错误:

9:3075328656] [info] ajp_connect_to_endpoint::jk_ajp_common.c (922): Failed opening socket to (69.164.218.75:8009) (errno=111)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [error] ajp_send_request::jk_ajp_common.c (1507): (dogself) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [info] ajp_service::jk_ajp_common.c (2447): (dogself) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [error] ajp_service::jk_ajp_common.c (2466): (dogself) connecting to tomcat failed.
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [info] jk_handler::mod_jk.c (2615): Service error=-3 for worker=dogself

我的 tomcat server.xml 如下所示:

<Service name="Catalina">


<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           URIEncoding="UTF-8"
           redirectPort="8443" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />



<Engine name="Catalina" defaultHost="dogself.com">


  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>


  <Host name="dogself.com"  appBase="webapps-dogself"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
  </Host>

  <Host name="nousophia.com"  appBase="webapps-test"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
  </Host>


</Engine>
</Service>

我的workers.properties如下所示:

# workers.properties - ajp13
#
# List workers
worker.list=dogself,nousophia

# Define dogself
worker.dogself.port=8009
worker.dogself.host=dogself.com
worker.dogself.type=ajp13

worker.nousophia.port=8009
worker.nousophia.host=nousophia.com
worker.nousophia.type=ajp13

tomcat 已启动/重新启动

我按照以下说明进行设置: https://stackoverflow.com/questions/1765399/linking-apache-to-tomcat-with-multiple-domains

有人能确认它能像上面那样工作吗?

答案1

您需要为第二个虚拟主机在不同端口上添加另一个连接器,因为 Apache 和 Tomcat 之间的 AJP 连接是持久连接。

例如,server.xml:

....
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
....

工人.属性:

worker.dogself.port=8009
worker.dogself.host=dogself.com
worker.dogself.type=ajp13

worker.nousophia.port=8010
worker.nousophia.host=nousophia.com
worker.nousophia.type=ajp13

相关内容