One Tomcat instance for two domains and two webapps

How to configure Tomcat (offline, without Apache [*]) so that I can deploy it on the same server and serve two different web applications, depending on the domain name I requested?

What is gotchas at the same time? Can you have SSL on both domains? If anyone here really did, I would be interested to answer these questions, as well as as many reviews as possible ...

I found a blog post describing such a setup, but for Tomcat 5.5:

<Engine defaultHost="domain1.com" name="Catalina"> <Host name="domain1.com" appBase="/home/user1/domain1"> <Alias>www.domain1.com</Alias> <Context path="" docBase="."/> </Host> <Host name="domain2.com" appBase="/home/user1/domain2"> <Alias>www.domain2.com</Alias> <Context path="" docBase="."/> </Host> 

http://iam-rakesh.blogspot.com/2009/10/hosting-multiple-domains-in-tomcat.html

Also, at the moment I have one webapp, ROOT.war, inside ... / tomcat / webapps /

How will this work when I have two β€œroots”, one root webapp for domain1.com and one root webapp for domain2.com? Where will the .war be located?

+6
source share
1 answer

The blog you linked basically shows how to do this. The only thing you need differently is to set the "docBase" attribute differently for each host. DocBase is the location of the war files for this host. With different docBases you can have different root applications.

+4
source

Source: https://habr.com/ru/post/909236/


All Articles