2
votes

I have installed Apache tomcat 8 on my windows server 2012 where I need to store my Java applications. I have 3 apps: app1, app2, app3

Right now if I put into my - Tomcat 8.0\webapps folder war file called ROOT.war app starts on address mydomain.com and works fine - but I need to be able to run several apps at the same tomcat - Thats's why I want to create subdomains

app1 should launch on app1.mydomain.com 
app2 should launch on app2.mydomain.com 
app3 should launch on app3.mydomain.com 

How can I fulfill this?

I search similar topics here on stack-overflow but nothing helped.

Please help.

1
Why not run each application on a different port, and let a web server manage that for you? - Nick Delaney
This application should be used by customers - for them it will be easier to remember app1.mydomain.com rather then app1.mydomain.com:8252 :) - Irakli
You missed the point I was making. The applications run on different ports. However the web server will handle the subdomain mapping. app1.mydomain.com will point to port 80, but the web server will map it to localhost:8252 - Nick Delaney

1 Answers

4
votes

Actually I solved my issue like this: I have configured server.xml file located in my case in Program Files (x86)\Apache Software Foundation\Tomcat 8.0\conf folder

found there this code:

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

made a copy of it and replaced the values with my subdomains:

 <Host name="app1.mydomain.com "  appBase="app1.mydomain.com "
        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>

and that's it actually.

For myself I also removed default localhost HOST and now I have only subdomains.