Search code examples
apachetomcatmod-proxymod-jk

multiple tomcat versions on one server


I maintain a webserver that contains 3 jsf2-web applications, deployed currently on tomcat7. Our architecture is set up using mod-jk from apache over port 80 to the three instances, one for each web application. Besides different other reasons, I need for one webapp tomcat8 and the others tomcat7. I couldn't figure out how to make this possible as I can only define one workers file in apache config. This is the server's architecture:

Internet -> Apache 2 (open on Port 80 only)
Tomcat 7 instance 1 on Port 8180
Tomcat 7 instance 2 on Port 8280
Tomcat 7 instance 3 on Port 8380

Queries from Web redirected to tomcat instances:
server/Webapp1 -> instance 1/Webapp1
server/Webapp2 -> instance 2/Webapp2
server/Webapp3 -> instance 3/Webapp3

Now what I want is instance 3 running on an Tomcat 8 instead of 7, but it must be available by apache due to the port limitations. The new architecture shall look like this:

Internet -> Apache 2 (open on Port 80 only)
Tomcat 7 instance 1 on Port 8180
Tomcat 7 instance 2 on Port 8280
Tomcat 8 instance 3 on Port 8380

Trying proxypass in a variety of configurations, I cannot use it as it would redirect to a port that isn't available from the internet.

Is there a way to redirect internally only as Tomcat 8 is a complete other process?


Solution

  • I figured out that mod_jk works for different installations of tomcat also, so I installed 3 tomcat packages and configured mod_jk to use each tomcat instance. The configuration of mod_jk (see apache modules folder) looks like this:

    <IfModule jk_module>
      JkWorkersFile /opt/workers.properties
      JkLogFile /var/log/apache2/mod_jk.log
      JkLogLevel warn
      JkShmFile /var/log/apache2/jk-runtime-status
      JkWatchdogInterval 60
      JkMountFile /opt/uriworkermap.properties
    </IfModule>
    

    The workers file looks like this:

    worker.list=app1, app2, app3
    worker.app1.port=8109
    worker.app1.host=localhost
    worker.app1.type=ajp13
    worker.app2.port=8209
    worker.app2.host=localhost
    worker.app2.type=ajp13
    worker.app3.port=8309
    worker.app3.host=localhost
    worker.app3.type=ajp13