As it allow to deploy many web application archive (.war), the question is how to asign different domain to each web application archive. The answer is by tuning the server.xml file in the ROOT/conf directory of your apache distribution.
Standard configuration
With the standard confiruation, .war archive are deploy within the ROOT/webapps directory of the apache distribution as denoted by the server.xml configuration file :<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
All you webapps are deploy under the same domain (associated with the ROOT/webapps directory) and can be accessed by changing the URL terminaison :- http://www.mydomain.com/webapp1
- http://www.mydomain.com/webapp2
- ...
Multi domain configuration
Tomcat allow you to simply bind domain names to specific directories. Each requested made to a specific domain will be handled by the web applications deployed into the mapped directory. You have to define Host within the Engine tag of the server.xml configuration file.<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Domain1 -->
<Host name="www.domain1.com" appBase="domain1"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Alias>fr.domain1.com</Alias>
<Alias>it.domain1.com</Alias>
<Alias>es.domain1.com</Alias>
<Alias>pt.domain1.com</Alias>
<Alias>de.domain1.com</Alias>
<Alias>nl.domain1.com</Alias>
</Host>
<!-- Domain2 -->
<Host name="www.domain2.com" appBase="domain2"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
<!-- Domain3 -->
<Host name="www.domain3.com" appBase="domain3"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
<!-- Default
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host> -->
</Engine>
Requests made to www.domain1.com and it's sub domains :- fr.domain1.com
- it.domain1.com
- ...
Requests made to www.domain2.com will be handled by the web application deployed into the ROOT/domain2 directory of the tomcat distribution.
Requests made to www.domain3.com will be handled by the web application deployed into the ROOT/domain3 directory of the tomcat distribution.
Publish multiple websites using a Single Tomcat web server, Multiple domains on a single Tomcat web server, Multiple hosted sites on a Tomcat server