Hosting 2 webapps under 1 apache/tomcat

apache-2.2mod-jktomcat6

I am trying to host multiple webapps under tomcat 6 behind apache2 via mod_jk.

I am at my wits end with this. the problem i am facing that both domains seems to point to a single tomcat 'domain'.

my 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" />
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="example.com">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

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

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

my workers.properties looks like this:

worker.list=example,example2

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

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

finally my apache vhosts look like this:

<VirtualHost 10.160.211.7:80>
    ServerName example.com
    DocumentRoot /srv/www/example.com/public_html/
    ErrorLog /srv/www/example.com/logs/error.log
    CustomLog /srv/www/example.com/logs/access.log combined

    JkMount  /* example
</VirtualHost>

and

<VirtualHost 10.160.211.7:80>
    ServerName example2.com
    DocumentRoot /srv/www/example.com/public_html/
    ErrorLog /srv/www/example.com/logs/error.log
    CustomLog /srv/www/example.com/logs/access.log combined

    JkMount  /* example2
</VirtualHost>

when i log into manager webapp on both example.com and example2.com, i can deploy to a context path on example, and that same contextpath will appear on example2 – so i know for a fact that this is the same tomcat domain.

edit: just found this in my mod_jk log

[Sun Feb 20 21:15:43 2011] [28546:3075521168] [warn] map_uri_to_worker_ext::jk_uri_worker_map.c (962): Uri * is invalid. Uri must start with /
[Sun Feb 20 21:16:44 2011] [28548:3075521168] [info] ajp_send_request::jk_ajp_common.c (1496): (example) all endpoints are disconnected, detected by connect check (1), cping (0), send (0)

but not sure why example wouldnt respond

please help a brother out

Best Answer

i was being an idiot. i ended up shutting down apache and connecting to 8080 on both domains. the problem persisted, so i knew it was not a mod_jk or apache issue.

the problem was that i was accessing both domains as www.domain but i didnt alias those subdomains in tomcat