0

I have two applications what need to be run on different ports:

  • Service.war on port 8080
  • Client.war on port 8300

Both of them should be unpacked to

  • $CATALINA_HOME/webapps/Service
  • $CATALINA_HOME/webapps/Client

(Ports and unpacking places are the restriction of build scripts specifics, I cannot influence it)

Below is the config I have now:

<Service name="Catalina8300">
    <Connector port="8300" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"/>

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine name="Catalina8300" defaultHost="localhost">
        <Realm className="org.apache.catalina.realm.LockOutRealm">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase"/>
        </Realm>
        <Host name="localhost" appBase="webapps"
              unpackWARs="true" autoDeploy="true">
            <Context docBase="Client" path="/Client"/>
            <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>
    </Engine>
</Service>

  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"/>

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine name="Catalina" defaultHost="localhost">
        <Realm className="org.apache.catalina.realm.LockOutRealm">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase"/>
        </Realm>
        <Host name="localhost" appBase="webapps"
              unpackWARs="true" autoDeploy="true">
            <Context docBase="Service" path="/Service"/>
            <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>
    </Engine>
</Service>

After the tomcat is started, both Client and Service apps are deployed to the 8080 port.

Is there a way to set up two services in server.xml to work on 8080 and 8300 ports, without having two different webapps folders as I saw in most of examples?

What should be the base app and hosts in the services in such a case?

Bohdan Nesteruk
  • 794
  • 17
  • 42
  • View this post: [https://stackoverflow.com/questions/8823290/how-to-run-different-apps-on-single-tomcat-instance-behind-different-ports][1] – Ofir Edi Feb 04 '20 at 13:13
  • View this post: [https://stackoverflow.com/questions/8823290/how-to-run-different-apps-on-single-tomcat-instance-behind-different-ports][1] – Ofir Edi Feb 04 '20 at 13:14
  • Thanks, but I saw it. appBase is suggested to have different values there (app1, app2). In my case it should be 'webapps' for both contexts. – Bohdan Nesteruk Feb 05 '20 at 08:50

0 Answers0