0

I am having trouble setting up tomcat6 with 2 virtual hosts, behind apache2.

if i have just one host defined in tomcat, and one jk worker, everything works fine. as soon as i define another jk worker and a corresponding tomcat host i get this error in 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

my tomcat server.xml looks like this:

<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>

my workers.properties looks like this:

# 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 is started/restarted

i followed these directions for setting it up: https://stackoverflow.com/questions/1765399/linking-apache-to-tomcat-with-multiple-domains

can someone confirm that it would work as above?

mkoryak
  • 171
  • 10

1 Answers1

1

You will need to add another Connector on a different port for the second virtual host, because the AJP connection between Apache and Tomcat is a persistent connection.

eg, server.xml:

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

workers.properties:

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
daveadams
  • 1,269
  • 6
  • 12
  • 1
    ok, then are you saying that the answer here is wrong: http://stackoverflow.com/questions/1765399/linking-apache-to-tomcat-with-multiple-domains – mkoryak Feb 08 '11 at 17:46
  • 1
    daveadam's answer will work. We had recently configured 3 virtual hosts in apache connecting to tomcat. Connector port has to be different for each separate worker. You can specify ports like 8009, 8010 and 8011 for 3 virtual hosts for example and so on. – webstat Aug 23 '12 at 08:31