Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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: http://stackoverflow.com/questions/1765399/linking-apache-to-tomcat-with-multiple-domains

can someone confirm that it would work as above?

share|improve this question

1 Answer 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
share|improve this answer
1  
ok, then are you saying that the answer here is wrong: stackoverflow.com/questions/1765399/… –  mkoryak Feb 8 '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. –  tushar Aug 23 '12 at 8:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.