You are on page 1of 5

How to Connect Apache to JBoss?

Note: This configuration is for JBoss version 5. To connect Apache to JBoss, first make sure that you undo the changes for all configuration files if you have done the tutorial How to Connect Apache to Tomcat before, so as to clear any conflict. 1. Go to http://www.apache.org/dist/tomcat/tomcatconnectors/jk/binaries/ and download the Apache Tomcat connector file mod_jk-1.2.28-http-2.2.3.so. (Or download here). Here you use the same connector as that of Tomcat, because Tomcat is embedded in JBoss.
2.

Rename the file name of mod_jk-1.2.28-http2.2.3.so to mod_jk.so, and copy it into your[ApacheHome]\modules. (If you have done this for Tomcat, you can skip this step.) Create a file called workers.properties with the following lines, (Or download here). Note: This version for JBoss is different from the one for Tomcat.

3.

# Define list of workers that will be used # for mapping requests # The configuration directives are valid # for the mod_jk version 1.2.18 and later # worker.list=loadbalancer,status # Define Node1 # modify the host as your host IP or DNS name. worker.node1.port=8009 worker.node1.host=localhost worker.node1.type=ajp13 worker.node1.lbfactor=1 # worker.node1.connection_pool_size=10 (1) # Load-balancing behaviour

worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=node1 # Status worker for managing load balancer worker.status.type=status


4.

Copy workers.properties into your [ApacheHome]\conf. (You may want to rename Tomcat'sworkers.properties to workers.propertie s.tomcat.) Under [ApacheHome]/conf, create the file modjk.conf with the following lines, (or just downloadhere)

5.

# Load mod_jk module # Specify the filename of the mod_jk lib LoadModule jk_module modules/mod_jk.so # Where to find workers.properties JkWorkersFile conf/workers.properties # Where to put jk logs JkLogFile logs/mod_jk.log # Set the jk log level [debug/error/info] JkLogLevel info # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" # JkOptions indicates to send SSK KEY SIZE # Note: Changed from +ForwardURICompat. # See http://tomcat.apache.org/securityjk.html JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories # JkRequestLogFormat

JkRequestLogFormat "%w %V %T" # Mount your applications JkMount /application/* loadbalancer # You can use external file for mount points. # It will be checked for updates each 60 seconds. # The format of the file is: /url=worker # /examples/*=loadbalancer JkMountFile conf/uriworkermap.properties # Add shared memory. # This directive is present with 1.2.10 and # later versions of mod_jk, and is needed for # for load balancing to work properly # Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to # https://bugzilla.redhat.com/bugzilla/show_b ug.cgi?id=225452 JkShmFile run/jk.shm # Add jkstatus for managing runtime data <Location /jkstatus/> JkMount status Order deny,allow Deny from all Allow from 127.0.0.1 </Location>
6.

Create the URI to worker map file uriworkermap.properties file in the [ApacheHome]/confdirectory with the following lines, (or just download here)

# Simple worker configuration file # # Mount the Servlet context to the ajp13 worker /jmx-console=loadbalancer /jmx-console/*=loadbalancer /web-console=loadbalancer /web-console/*=loadbalancer /Du*=loadbalancer
The last line tells Apache to forward all the URLs that match the pattern /Du* to JBoss. The reason that we use the pattern /Du* here is for testing purpose - we will use the Duke example for testing. Download the JBoss version of the Duke example here . The JBoss version of the Duke is different from the Tomcat version of the Duke. 7. Add the following two lines at the very bottom in [ApacheHome]/conf/httpd.conf,

# Include mod jk configuration file Include conf/mod-jk.conf


8. 9. Restart Apache. Configure the embedded Tomcat inside JBoss by editing the following file

[JBossHome]/server/default/deploy/jbossweb. sar/server.xml
10.

Locate the <Engine> element and add an attribute jvmRoute as follows,

<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node1"> ... </Engine>

The value of jvmRoute attribute must match the name specified in workers.properties. 11. In the server.xml file, make sure that the AJP 1.3 Connector is uncommented,

<Connector protocol="AJP/1.3" port="8009" address="${jboss.bind.address}" redirectPort="8443" />


12.

Restart JBoss, and deploy the Duke example to [JBossHome]/server/default/deploy/.

13. To test if the connection between Apache and JBoss works, visit the URL: http://localhost/Duke. ==========The End==========

You might also like