Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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