Question

I have two web applications, which I want to be running under the one tomcat instance, but on a different ports to connect, for example first war - under 8080, and second - 8090. Is it possible to do using just two connectors in the server.xml?

So to connect to first app - i'll use address http://localhost:8080/myFirstApp and for second - http://localhost:8090/mySecondApp. How can I do this without running two tomcat innstances on the localhost?

Was it helpful?

Solution

Well, I think you can declare the two connectors with different ports and they will run properly. But you can't limit the access to apps via configuration. That is - both apps will be accessible on both ports. If you need to limit that, make a Filter that checks and returns 404.

OTHER TIPS

There's no problem with running two connectors.

But if you want to have each app accessible on different port and only there (not on both/all ports), copy Service part in conf/server.xml changing the ports and names so that there's no conflict.

You'll have to specify different webapps directories for both Services and put each of your webapps in different one.

http://www.mulesoft.com/tomcat-connector

Now let's assume that we want to change this configuration, so that instead of receiving two responses for every request received by either Connector, we want each Connector to pass requests from its port only to one specific web application. To achieve this functionality, we simply need to rearrange the element hierarchy so that it resembles something like this:

<Server>
  <Service name="Catalina">
    <Connector port="8443"/>
    <Engine>
       <Host name="yourhostname">
          <Context path="/webapp1"/>
       </Host>
    </Engine>
  </Service>
  <Service name="Catalina8444">
    <Connector port="8444"/>
    <Engine>
       <Host name="yourhostname">
          <Context path="/webapp2"/>
       </Host>
    </Engine>
  </Service>
</Server>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top