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?


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"
  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false"

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


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.