Académique Documents
Professionnel Documents
Culture Documents
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
C USTO ME R PO RTAL
Products & Services Knowledgebase
Apache 2.x and JBoss EAP 4 / 5?
Solutions
0 ISSUE
How do I install and congure mod_jk with Apache and JBoss?
How to congure the communication between our JBossEAP5 and JbossWebserver?
ENVIRONMENT
JBoss Enterprise Application Platform (EAP)
4.2
4.3
5
JBoss Enterprise Web Server (EWS)
mod_ jk 1.2
Apache 2
, RESOLUTION
Quick Overview
1. Download Apache2/Use existing Apache (EWS is the ofcially supported JBoss version of
Apache)
https://access.redhat.com/solutions/18414
1/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
2. Download the supported modjk 1.2.x (See component matrix which includes the mod_ jk
version at http://www.jboss.com/products/platforms/application/components/
(http://www.jboss.com/products/platforms/application/components/)) mod_ jk.so comes
with the EWS and the EAP 5+ Native builds.
3. Change the main Apache cong to include mod_ jk cong
4. Create the mod_ jk cong
5. Congure the mod_ jk workers (which JBoss/Tomcat nodes Apache uses)
6. Congure the Apache URIs served by modjk (the applications served by JBoss/Tomcat)
7. Restart Apache
8. Congure Tomcat (Give each JBoss/Tomcat a jvmRoute for session stickness)
9. Restart JBoss
10. Test it
More Details
This wiki outlines the various steps required to install a basic load-balancing solution based
on JBoss/Tomcat and mod_ jk 1.2.
For quick generation of optimized mod_ jk congurations please see
http://lbcong.appspot.com (http://lbcong.appspot.com).
Step 1: Download Apache2 Web Server
Apache can be installed through RHN with certain Red Hat/JBoss entitlements such as the JBoss
Enterprise Web Server (EWS) In the community Apache can also be obtained through
http://httpd.apache.org though it will be unsupported in the enterprise realm.
In the following steps, $APACHE_HOME will represent the Apache install directory.
Step 2: Download mod_ jk 1.2.x
mod_ jk can also be installed through RHN from the above entitlements or downloaded through the
EWS or EAP 5+ Native builds or unsupported through http://tomcat.apache.org/downloadconnectors.cgi Always download the latest stable release if possible. Rename the lib
mod_ jk.so and drop it in $APACHE_HOME/modules directory.
Step 3: Setup Apache to use modjk
Add this line at the very bottom in $APACHE_HOME/conf/httpd.conf :
https://access.redhat.com/solutions/18414
2/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
#Includemod_jkconfigurationfile
Includeconf/modjk.conf
3/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
#https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFilerun/jk.shm
#Addjkstatusformanagingruntimedata
<Location/jkstatus>
JkMountstatus
Orderdeny,allow
Denyfromall
Allowfrom127.0.0.1
</Location>
mod_ jk is ready to forward requests to JBoss instances. We need now to setup the workers
Note: As of mod_ jk 1.2.6+ you need to include "JkMountCopy all" in the mod_ jk conguration if you
intend to specify global JkMount's or JkMountFile's instead of per VirtualHost. If you do not want to
copy the same JkMount/JkMountFile for each VirtualHost, you can specify "JkMountCopy On"
inside the VirtualHost directive.
See entry in: http://tomcat.apache.org/connectors-doc/reference/apache.html
(http://tomcat.apache.org/connectors-doc/reference/apache.html)
https://access.redhat.com/solutions/18414
4/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
#Definelistofworkersthatwillbeused
#formappingrequests
#Theconfigurationdirectivesarevalid
#forthemod_jkversion1.2.18andlater
#
worker.list=loadbalancer,status
#DefineNode1
#modifythehostasyourhostIPorDNSname.
worker.node1.port=8009
worker.node1.host=node1.mydomain.com
worker.node1.type=ajp13
worker.node1.ping_mode=A
#DefineNode2
#modifythehostasyourhostIPorDNSname.
worker.node2.port=8009
worker.node2.host=node2.mydomain.com
worker.node2.type=ajp13
worker.node2.ping_mode=A
#Loadbalancingbehaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
#Statusworkerformanagingloadbalancer
worker.status.type=status
5/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
#Simpleworkerconfigurationfile
#
#MounttheServletcontexttotheajp13worker
/jmxconsole=loadbalancer
/jmxconsole/*=loadbalancer
/webconsole=loadbalancer
/webconsole/*=loadbalancer
/myapp/*=loadbalancer
!/myapp/images/*=loadbalancer
This will congure mod_ jk to forward requests for the /jmxconsole, /webconsole and /myapp
contexts to JBoss Web. The '!' at the beginning of the last line results in the URLs for the images dir
in the myapp context not being forwarded. Instead httpd will handle them directly (which means they
must be available on the httpd server).
Step 7: Restart Apache
Step 8: Congure the JBoss EAP
To complete the conguration, we also need to name each node to match the names specied in
workers.properties.
To do this, edit the server.xml le. Where server.xml is located depends on the version of JBoss:
In JBoss 5, it's $JBOSS_HOME/server/$PROFILE/deploy/jbossweb.sar/server.xml
In JBoss 4.2.x and EAP 4.x, it's
$JBOSS_HOME/server/$PROFILE/deploy/jbossweb.deployer/server.xml
Inearlierreleasesit's$JBOSS_HOME/server/$PROFILE/deploy/jbosswebtomcatXX.sar/server.xml
where XX is 40, 50, 55 etc depending on the Tomcat version embedded in the AS.
Locate the <Engine/.> element and add an attribute jvmRoute:
<Enginename="jboss.web"defaultHost="localhost"jvmRoute="node1">
.
</Engine>
The jvmRoute attribute value must match the name specied in workers.properties.
In the server.xml le, make sure that the AJP 1.3 Connector is uncommented, e.g.:
<!AAJP1.3Connectoronport8009>
<Connectorport="8009"address="${jboss.bind.address}"
emptySessionPath="true"enableLookups="false"redirectPort="8443"
protocol="AJP/1.3"connectionTimeout="600000"maxThreads="200"/>
https://access.redhat.com/solutions/18414
6/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
If you are only accepting requests via mod_ jk, you can comment out the regular HTTP Connector;
Tomcat then won't listen on port 8080.
Step 9: Activate the JvmRouteValve in JBoss (not needed with Tomcat Standalone)
Finally, we need to tell JBoss to add a special valve that detects when failover of a session from a
distributable webapp has occurred. This JvmRouteValve ensures a new session cookie is emitted
that includes the jvmRoute of the server that is now handling the session.
This conguration step is only needed with JBoss 4.2.x and earlier; beginning with JBoss 5 the
application server uses the existence of a jvmRoute conguration in server.xml as an indication that
it should add the JvmRouteValve.
To do this, edit the jbossservice.xml le for the JBoss Web service. Where this is located
depends on the version of JBoss AS:
In JBoss 5, this step isn't needed.
In JBoss 4.2.x and EAP 4.x, it's
$JBOSS_HOME/server/$PROFILE/deploy/jbossweb.deployer/METAINF/jbossservice.xml
Inearlierreleasesit's$JBOSS_HOME/server/$PROFILE/deploy/jbosswebtomcatXX.sar/``METAINF/jb
where XX is 40, 50, 55 etc depending on the Tomcat version embedded in the AS.
Locate the <attribute> element with a name of UseJK, and set its value to "true" (not applicable to
EAP 5):
<attributename="UseJK">true</attribute>
Note: You may need to use VirtualHost in you mod-jk.conf. For example:
Instead of just
JkMount/jmxconsoleloadbalancer
JkMount/jmxconsole/*loadbalancer
try
https://access.redhat.com/solutions/18414
7/9
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
<VirtualHosthost.name.or.IP>
ServerNamehost.name.or.IP
JkMount/jmxconsoleloadbalancer
JkMount/jmxconsole/*loadbalancer
</VirtualHost>
Further reference
See Troubleshooting & Optimizing mod_ jk (/knowledge/node/18415) for optimizing mod_ jk
for your specic environment
See Troubleshooting & Optimizing mod_ jk (/knowledge/node/18415) if you encounter issues
with mod_ jk
See [DOC-34454]Does Red Hat / JBoss offer support for Apache / mod_ jk / mod_proxy /
mod_cluster? (/knowledge/node/18495) for information pertaining to mod_ jk support
Product(s)
Red Hat JBoss Enterprise Application Platform (https://access.redhat.com/search/browse/solutions#?
&portal_product=Red+Hat+JBoss+Enterprise+Application+Platform)
Red Hat JBoss Web Server (https://access.redhat.com/search/browse/solutions#?
&portal_product=Red+Hat+JBoss+Web+Server)
Component
Category
Tags
jbossas (https://access.redhat.com/search/browse/solutions#?&portal_component=jbossas)
Learn more (https://access.redhat.com/search/browse/solutions#?&portal_category=Learn+more)
apache (https://access.redhat.com/search/browse/solutions#?&portal_tag=apache)
COMMENTS
(/user/1162213)
Jim Tyrrell
(/user/1162213)
https://access.redhat.com/solutions/18414
12/24/2014
HowdoIinstallandconfiguremod_jk1.2.2xwithApache2.xandJBossEAP4/5?RedHatCustomerPortal
Red Hat
Stopping httpd:
[FAILED]
Newbie
5 points
Formatting Help
SUBMIT COMMENT
https://access.redhat.com/solutions/18414
9/9