2

I have two domains but only one virtual server which runs a tomcat 7. I have my own ubuntu Linux with full root access running on the virtual server. I setup shorewall firewall which forwards any request on port 80 to port 8080 (where tomcat is listening on).

So I already searched the net but I only find "solution" that do not work in my case. This is what I did so far:

  1. I copied my websiteA.war as ROOT.war into the $CATALINA_HOME/webapps/ folder
  2. I also copied my websiteB.war as WebsiteB.war into the $CATALINA_HOME/webapps/ folder
  3. I modified my $CATALINA_HOME/conf/server.xml in the following way:

    Host name="www.websiteA.com" appBase="webapps" unpackWARs="true" autoDeploy="true"

    Host name="www.websiteB.de" appBase="webapps/websiteB" unpackWARs="true" autoDeploy="true"

    Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"

  4. I created the following file ROOT.xml in the folder "$CATALINA_HOME/conf/Catalina/www.websiteB.com" :

    ?xml version="1.0" encoding="UTF-8"?

    Context displayName="www.websiteB.com" docBase="" path=""

    /Context

  5. Restarted tomcat. The websiteA.com gets deployed under "/" and websiteB.com gets deployed unter "/websiteB"

  6. Entering www.websiteB.com arrives at "/" which means that websiteA is actually shown for websiteB.com

What am I doing wrong here?

2
  • Hey, did you get an answer to this? Commented Mar 27, 2018 at 13:32
  • Yeah, just updated this very old question with an answer. Commented Apr 9, 2018 at 6:28

1 Answer 1

2

Goto your $CATALINA_HOME/conf/server.xml file.

There, you will find the following section:

<Engine name="Catalina" defaultHost="localhost"> <!-- ... some other stuff ... --> <Host name="www.websiteA-Address" appBase="webapps" unpackWARs="true" autoDeploy="true"></Host> <Host name="www.websiteB-Address" appBase="directory/of/WAR-files-for-B" unpackWARs="true" autoDeploy="true"></Host> <Host name="websiteB-Address" appBase="directory/of/WAR-files-for-B" unpackWARs="true" autoDeploy="true"></Host> <Host name="www.websiteC-Address" appBase="directory/of/WAR-files-for-C" unpackWARs="true" autoDeploy="true"></Host> </Engine> 

So, appBase will be the directory where your will have to put your ROOT.war(!) and name is the domain name that will be mapped onto this directory.

directory/of/WAR-files is a subdirectory in $CATALINA_HOME, that is the same level(!!!) as the standard folder webapps. So both directories coexist!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.