Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Multiple Instances of Tomcat on same port

I need to run multiple instances of tomcat6 under different directory names on the same port. I will install tomcat6 twice for two different projects. But how to configure both the instances to run on the same port?

like image 478
franklin joseph Avatar asked Oct 17 '25 17:10

franklin joseph


2 Answers

You could realise this using an apache webserver that is directing the requests based on the application using mod_jk or mod_proxy. (and get an explanation on both extensions)

To choose which apache extension to use: apache to tomcat: mod_jk vs mod_proxy

like image 152
Kurt Du Bois Avatar answered Oct 22 '25 00:10

Kurt Du Bois


Yes, you can. In server.xml replace:

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->
    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>

By

<Host name="app1.com"  appBase="webappsApp1" unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>

<Host name="app2.com"  appBase="webappsApp2" unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>

In the webappsApp1 directory you put the war of App1, the same for webappsApp2 directory and App2.

In dns zone of App1 and App2 put the public ip of the server.

like image 24
victorpacheco3107 Avatar answered Oct 22 '25 01:10

victorpacheco3107



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!