0

Is it possible to configure tomcat to have 2 virtual hosts one is configured with an alias that matches a domain name that is configured in my dns. The other virtual host needs to respond to requests sent directly to the ip address of the server. Is this possible? How do I configure the second virtual host?

1 Answer 1

1

The documentation on using tomcat for virtual hosting suggests you would want to modify your server.xml to include an additional Host element like so;

<Engine name="Catalina" defaultHost="localhost">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>
  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false"
            deployIgnore=".svn">
  </Host>

<Host name="123.123.123.123" appBase="extraserver"/>

</Engine>

and then make the required parallel directories using the following steps;

mkdir $CATALINA_HOME/extraserver
mkdir $CATALINA_HOME/conf/Catalina/extraserver

(where you would have to set you $CATALINA_HOME and extraserver as appropriate.

then you would be able to deploy your apps using autodeploy, but to the alternative webapps appsBase.

1
  • Change your second <Host>'s name to the IP address instead of "www.extraserver.com" and you'll get my upvote. May 24, 2012 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .