Sunday, February 06, 2011

Multiple domains with tomcat behind apache

This is how you would host multiple domains/webapps on a single tomcat behind apache via mod-jk.

first setup tomcat behind apache

I am setting up a new domain called

in server.xml add this under last host:

<Host name=""  appBase="webapps-dogself"
  unpackWARs="true" autoDeploy="true"
  xmlValidation="false" xmlNamespaceAware="false">
and also add another connector port:
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> 

create a webapps-dogself directory next to webapps and give it the same permissions

in your virtualhost apache config:
JkMount  /* dogself 
in add dogself worker to list:

# Define dogself

If you want the manager app to work on the domain you need to:
mkdir /etc/tomcat6/Catalina/ 

and copy the manager.xml into it from /etc/tomcat6/Catalina/localhost

in /var/lib/tomcat6 create a webapps-dogself dir and give it 0775 perms and chown it to tomcat:tomcat

restart tomcat and apache

if you get error:
worker dogself can't resolve tomcat address
Check that your dns a/aaaa records point to your ip. Comment out the worker in and see if you can get to the apache vhost.

if any of the domains seems to point to another domain, ie the war that is running on one domain is incorrect. check if you are in the www.domain and if you have aliased the www both in tomcat and in apache. if you dont alias the www correctly tomcat will send you the the defaultDomain as defined in server.xml

1 comment: