How to run different apps on single Tomcat instance behind different ports?

DeeStackOverflow picture DeeStackOverflow · Jan 11, 2012 · Viewed 79.2k times · Source

Currently I have 2 web applications app1 and app2 running on Tomcat 6:

I want to configure Tomcat so that they run in root context behind separate ports:

What needs to be done?

Answer

Benoit Marilleau picture Benoit Marilleau · Jan 11, 2012

I think you can configure that in you server.xml file and put 2 services :

<Service name="app1">
   <Connector port="8081" protocol="org.apache.coyote.http11.Http11NioProtocol" 
           connectionTimeout="20000" 
           redirectPort="8443" />
   <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="app1"
        unpackWARs="true" autoDeploy="true">
      </Host>
   </Engine>
</Service>
<Service name="app2">
   <Connector port="8082" protocol="org.apache.coyote.http11.Http11NioProtocol" 
           connectionTimeout="20000" 
           redirectPort="8443" />
   <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="app2"
        unpackWARs="true" autoDeploy="true">
      </Host>
   </Engine>
</Service>