tomcattomcat6port

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


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?


Solution

  • 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>