0
votes

I am trying to configure my (internal) test server to run 2 tomcat applications (actually 2 versions of the same one side by side). We are using Apache2.4 with mod_jk & Tomcat8. At the moment I am trying to work downwards and so the first step I am trying is to get the current (embedded) tomcat application to continue to run properly on port 80 and to initially fail to run a non existent application on port 81.

So currently it works with one application on

http://LOCALSERVERNAME

My changes have it working (same app) on

   1) http://LOCALSERVERNAME

and

   2) http://LOCALSERVERNAME:81

but I want it to continue to work as is for 1 and run a different application for 2.

So I've modified the httpd.conf to listen on both ports

Listen 80
Listen 81

With the existing jkMount setting this

JkMount /* worker1
JkMount /localhost:80 worker1
JkMount /localhost:80/* worker1
JkMount /127.0.0.1:80 worker1
JkMount /127.0.0.1:80/* worker1

opens the tomcat app on both ports (and not on other ports) so the listener directives are working. I think this is just using JkMount /* worker1 however.

I modified this in the interim by commenting that out and trying both the options below (separately)

#JkMount /* worker1
#JkMount /*:80/* worker1
JkMount /194.66.181.17:80/* worker1

I have set the servername entry to the local server name

ServerName LOCALSERVERNAME

this is giving me an authentication required logon popup & 401 error despite there being no password protection on the apache server. I'm assuming this is an error in the config.

I have modified the worker.properties from the one I inherited and on browsing for a solution I think I may have misunderstood it's purpose. It was using a balancer (with the same issies as noted) and I modified it thinking I would be using it to feed the tomcat apps with different ports (8009 & 8011). I have seen someone saying that the worker.properties file is only really for using as a load balancer so maybe this was a mistake ?

worker.list=worker1, worker2

worker.worker1.port=8009 
worker.worker1.host=localhost 
worker.worker1.type=ajp13

worker.worker2.port=8011 
worker.worker2.host=localhost 
worker.worker2.type=ajp13

My httpd-vhosts.conf file looks like this although I have tried lots of things in the 2nd entry and I don't think they are ever picked up - I think the closest I have had it to working has been when both ports 80 & 81 have run to the (same) existing app and has probably just used the first entry.

<VirtualHost [IP-address]:80 localhost:80>
    servername LOCALSERVERNAME
    DocumentRoot "E:/Production/Apache/htdocs"
    <Directory "E:/Production/Apache/htdocs"> 
        Options +FollowSymLinks
        AllowOverride All
    </Directory>

    JkOptions     +ForwardURICompatUnparsed
    ProxyRequests off
    JkMount /* worker1
</VirtualHost>


<VirtualHost [IP-address]:81>
    servername LOCALSERVERNAME
    DocumentRoot "E:/Production/Apache/dummy"
</VirtualHost>

So... my question is can I use apache on my local domain server to run 2 embedded tomcat applications using mod_jk ? If so can anyone point out where my config has gone wrong ? I'm assuming I'm going in the wrong direction somewhere rather than needing a minor tweak ?

1

1 Answers

0
votes

I'd rather use two virtual hosts through the same 80 port, even just for concept reasons.

But the issue here is mainly that your configuration does not work, I guess due to the fact that I think (or at least I've never seen it working this way) that your way of configuring the directives JkMount /localhost:80 worker1 does not work. As you guess, I'm pretty sure that the only one rule is working in your first config is JkMount /* worker1.

So my choice would be the creation of two name based virtual hosts, and set the JkMounts inner to each of them, more or less this way:

<VirtualHost *:80>
    servername prod.LOCALSERVERNAME
    DocumentRoot "E:/Production/Apache/htdocs"
    <Directory "E:/Production/Apache/htdocs"> 
        Options +FollowSymLinks
        AllowOverride All
    </Directory>

    JkOptions     +ForwardURICompatUnparsed
    ProxyRequests off
    JkMount /* worker1
</VirtualHost>


<VirtualHost *:80>
    servername dummy.LOCALSERVERNAME
    DocumentRoot "E:/Production/Apache/dummy"

    JkOptions     +ForwardURICompatUnparsed
    ProxyRequests off
    JkMount /* worker2
</VirtualHost>