Configuration Apache with mod_jk
Configurations:
/etc/cluster/cluster.conf:
<rm log_level="7" central_processing="1">
<failoverdomains>
<failoverdomain name="jboss_domain" ordered="1" restricted="1">
<failoverdomainnode name="axqad120-1" priority="1"/>
<failoverdomainnode name="axqad120-2" priority="1"/>
</failoverdomain>
<failoverdomain name="apache_domain" ordered="1" restricted="1">
<failoverdomainnode name="axqad120-3" priority="1"/>
<failoverdomainnode name="axqad120-4" priority="1"/>
</failoverdomain>
</failoverdomains>
<resources/>
<service autostart="1" name="protixvip1" domain="apache_domain">
<ip address="192.168.10.240" monitor_link="1"/>
<apache name="protixapache"/>
</service>
</rm>
/etc/httpd/conf.d/mod_jk.conf:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /etc/httpd/conf.d/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info
# Mount examples
#JkMount /servlets-examples/* jkworker
#JkMount /jsp-examples/* jkworker
JkMount /ClusterWeb/* protixrouter
# Enable the JK manager access from localhost only and local network for validation!
<Location /jkmanager/>
JkMount protixjkstatus
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.0.0/16
</Location>
/etc/httpd/conf.d/workers.properties:
# The advanced router LB worker and status checking for health checks of mod_jk servers.
worker.list=protixrouter,protixjkstatus
# Define the LB worker
worker.protixrouter.type=lb
worker.protixrouter.balance_workers=protixworker1,protixworker2
# Define a 'jkstatus' worker using status
worker.protixjkstatus.type=status
# Define a worker using ajp13
worker.protixworker1.port=8009
worker.protixworker1.host=axqad120-1.cc.atix
worker.protixworker1.route=axqad120-1
worker.protixworker1.type=ajp13
worker.protixworker1.lbfactor=1
# Define preferred failover node for worker1
#worker.protixworker1.redirect=worker2
# Define another worker using ajp13
worker.protixworker2.port=8009
worker.protixworker2.host=axqad120-2.cc.atix
worker.protixworker2.route=axqad120-2
worker.protixworker2.type=ajp13
worker.protixworker2.lbfactor=1
# Disable worker2 for all requests except failover
#worker.protixworker2.activation=disabled
# Define preferred failover node for worker1
#worker.protixworker2.redirect=worker1
Mod_jk loadbalancing:
The overall result is that workers managed by the same lb worker are load-balanced (based on their lbfactor and current user session) and also fall-backed so a single Tomcat process death will not "kill" the entire site.
Session stickiness
If you want to use session stickiness, you must set different jvmRoute attributes in the Engine element in Tomcat's server.xml. As we are using JBoss we need to keep track on session stickiness via JBoss !?. Furthermore the names of the workers which are managed by the balancer have to be equal to the jvmRoute of the Tomcat instance they connect with.