Ok

So I have got multiple tomcat instances setup on several AJP ports, I additionally have Apache httpd listening on port 8090 (cos I have got another application already using 8080 right now).

I have effectively planned web addresses for example mydomain.com:8090/demo and mydomain.com:8090/preprod for their particular tomcat instances using Jk Mount and also the following vhosts config

<VirtualHost *:8090>
    JkMount /preprod* preprod
    JkMount /demo* demo
</VirtualHost>

However I likewise want the "root" address to map to a different tomcat instance, what's going to become live/production, ie I would like mydomain.com:8090/ to map a 3rd tomcat instance.

Right now nothing happens or changes basically just increase the above config a line

JkMount /* rootwar

basically browse to mydomain.com:8090 I simply obtain the same boring apache httpd website landing page letting me know its running (ie index.html in httpd/htdocs)

Can you really use JkMount to redirect the "root" address stuff to some tomcat instance?

I can tell that the rule like /* will even match Web addresses like mydomain.com/preprod however i was wishing the guidelines are used in order therefore if /* seems in the finish it effectively will be a "if it is not among the other conditions, then direct to root/production"

Simply to be obvious I am attempting to setup the next

mydomain.com:8090/preprod --> myApp running in tomcat1
mydomain.com:8090/demo    --> myApp running in tomcat2
mydomain.com:8090         --> myApp running in tomcat3

So works out I had been right concerning the fall through behavior from the JkMount stuff, thus a config like

<VirtualHost *:8090>
    JkMount /preprod* preprod
    JkMount /demo* demo
    JKMount /* root
</VirtualHost>

is effective, web addresses with /preprod inside them reached tomcat1, /demo would go to tomcat2 and other things would go to tomcat3 for root. Therefore the JkMount /* root lines are clearly the final rule attempted and just "catches all" (cos its /*) if no other rules have matched up the url.

Great.

I've not labored using the jk stuff for while but so far as I recall this is not possible. We usually labored for this with the addition of a little html page which redirect towards the /root jk mount. Maybe utilizing a mod_rewrite rule may also work.

Something similar to this:

RewriteEngine on
RewriteRule ^/?(.+)$ /root/$1 

You can also hide the redirect with a little more complicated rewrite rules, a good example are available here:

http://www.webmasterworld.com/apache/4277304.htm

OK - not really a direct response to your question, but...an alternate is always to run all of demo/preprod and prop in separate instances, each on different ports.

This could have the benefit of simplifying your configuration but more to the point you may make changes to every instance (e.g. bouncing the server) without having to worry about affecting the development instance and brining it offline.

Jetty can also be excellent for situations such as this, specifically for running fast and dirty dev and demo instances....you are able to write a simple script that essentially just points in a deployment and begins a jetty instance onto it on some port:

public static void run(int port, String resourceBase, String descriptor) {
    Server server = new Server(port);

    WebAppContext context = new WebAppContext();
    context.setResourceBase(resourceBase);
    context.setDescriptor(descriptor);
    context.setContextPath("/");
    context.setParentLoaderPriority(true);
    server.setHandler(context);

    try {
        server.start();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

where

  • resourceBase is /path/to/webapp
  • descriptor is generally resourceBase+"/WEB-INF/web.xml"