0

I want to host multiple applications on different ports on single instance of tomcat. I have gone through the following link and made the following changes in my /etc/tomcat/server.xml file and added the following lines.

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

Server.xml

    <Service name="app1">
   <Connector port="8082" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443" />
   <Engine name="Catalina1" defaultHost="localhost">
      <Host name="localhost"  appBase="app1"
        unpackWARs="true" autoDeploy="true">
      </Host>
   </Engine>
</Service>

<Service name="app2">
   <Connector port="8083" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443" />
   <Engine name="Catalina2" defaultHost="localhost">
      <Host name="localhost"  appBase="app2"
        unpackWARs="true" autoDeploy="true">
      </Host>
   </Engine>
</Service>

In the appBase I have provided both the ways. 1. direct folder name. 2. path : webapps/temp.

The problem is when I hit the port 8082 and 8083, I dont get the default page It works for tomcat. and I am not able to make call to my url.

Eg : ip:8082/temp/xyz/abc/param1=hello&param2=world
ip:8083/temp/xyz/abc/param1=hello&param2=world

When I see in network I am getting 404 error for my url.

But if Call the same url using port 8081 (Default configuration in server.xml) it works perfectly fine I get the response correctly.

What I am doing wrong here.

Also If possible please tell me the drawbacks and problems if I proceed in this way, to host multiple application on single tomcat instance.

Thanks

Community
  • 1
  • 1
Shivkumar Mallesappa
  • 2,875
  • 7
  • 41
  • 68

1 Answers1

0

There are multiple issues with your current configuration. I recommend that you read though the other question you linked to carefully. Specifically:

  • Service names must be unique
  • Engine names must be unique
  • appBase values must be unique
  • appBase values must not overlap

Personally, I wouldn't do it this way. I'd run everything under a single service/engine and use virtual hosting. You need to set up a DNS name for each service but with virtual hosting you avoid users having to include the port number in the URL they use to access the service.

Mark Thomas
  • 16,339
  • 1
  • 39
  • 60
  • Sir I have edited my question and made changes according to the points you have suggested.But I am still not able to get the response. And thank you very much for sharing virtual hosting. This is the first time I am doing some thing like this. – Shivkumar Mallesappa May 04 '16 at 07:44