javatomcatpathwarcontextpath

Tomcat - nested webapp pathing without using Apache HTTPD


I'm again trying things I probably shouldn't... but... usually I get the feeling it's possible. This time, I'm really crossing my fingers.

I have a Tomcat 8 instance. On this instance, I have:

I don't want to run Apache HTTPD (or any other additional service layers). I also want to make this seemless at the tomcat level instead of trying to fake it via ingress networking/waf/etc or through the application itself (allow developer to work on other needed coding).

What I really want is to configure Tomcat in a way that will handle this by itself:

Now I tried following the Virtual Host configuration (https://tomcat.apache.org/tomcat-8.0-doc/virtual-hosting-howto.html) with little changes here to see if I can make this fit what I need... and... it's failing, but I think that if tomcat can do this, I can get it there.

What I've tried so far:

I've seen a few posts where they kind of do this, but in the opposite direction (root web directory points to some custom server path). I think I can get this config figured out, but I have to ask... will this strategy even work for what I'm trying to do with tomcat? Or am I in the wrong ballpark completely?

Thanks a bunch for your time. Always Appreciated!


Solution

  • In fact, you want nested contexts by Tomcat configuration only.

    This was talked about on the Tomcat User's List and you can have a look at this archived thread about nested contexts.

    From my understanding, the solution given relies on two contexts configuration :

    $TOMCAT_BASE/conf/Catalina/localhost/A.xml
    $TOMCAT_BASE/conf/Catalina/localhost/A#service.xml
    

    with directories webapps/A and webapps/A#service (this one containing the deployed appB content).