Tuesday, September 30, 2014

Tomcat integration with Apache webserver

AJP (Apache JServ protocol) is a communications protocol developed by apache.org to facilitate integration of the Tomcat container with third party web servers.Web server specific AJP plugins have been developed for Apache, IIS and Netscape's iPlanet.mod_jk.so  module developed to integrate the Apache web server with Tomcat container.

Steps to integrate the Apache webserver with Tomcat Container

  • Load the module as below in httpd.conf file

                 LoadModule jk_module modules/mod_jk.so

  • Add the below entry in httpd.conf file

Note: If virtual hosts configured , place the below configuration in virtual host block

<IfModule mod_jk.c>
     
      JkWorkersFile /data/apache/http-2.0.0.3/conf/workers.properties
      JkLogFile /data/apache/http-2.0.0.3/logs/mod_jkLog.log
      JkShmFile /tmp/jk-runtime-status
      JkLogLevel info
      JkMount /singleapp* Server-s
      JkMount /clusterapp* Server-c
   
</IfModule>

Create the worker.properties file as below 

workers.properties
-------------------------------------
worker.list=Server-s,Server-c  (Worker Nodes)
worker.Server-c.type=lb
worker.Server-c.balanced_workers=Server-c1, Server-c2 (Clustered Nodes)
worker.Server-c.sticky_session=1

worker.Server-c1.port=8009
worker.Server-c1.host=Server-c1.com
worker.Server-c1.type=ajp13
worker.Server-c1.lbfactor=1
worker.Server-c1.ping_mode=A

worker.Server-c2.port=8009
worker.Server-c2.host= Server-c2.com
worker.Server-c2.type=ajp13
worker.Server-c2.lbfactor=1
worker.Server-c2.ping_mode=A

worker.Server-s.port=8009
worker.Server-s.host=Server-s.com
worker.Server-s.type=ajp13
worker.Server-s.lbfactor=1
worker.Server-s.ping_mode=A

Server-s is single node and pointing to single tomcat server
Server-c is Cluster node and pointing to two clustered tomcat servers

No comments:

Post a Comment