Sunday, 16 November 2008

Apache httpd 2.x -> Glassfish 2.x mod_jk installation

Configure Apache Httpd to Glassfish using mod_jk.

, for Glassfish 3.x this process has been simplified, I'll probably add a blog entry about that sometime soon.

In this particular scenario, Apache 2.2.3 is running on Centos 5.2 x86_64 and Glassfish 2ur2 is running on OpenSolaris 10 b101, althought the process should be essentiually the same for any Operating system(s), the paths etc might change.

Apache httpd setup:

Get the Apache mod_jk connector.

Binary distribution:

Install into modules directory: e.g. /etc/httpd/modules (RH/Centos)

Configure Apache httpd:

e.g. for RH/Centos in - /etc/httpd/conf.d/

Add ajp worker mapping to httpd.conf (e.g. in /etc/httpd/conf/), in this example using virtual host entries, e.g.

# Virtual host

DocumentRoot /var/www/mywebs/



DirectoryIndex index.html index.php index.htm index.shtml

JkMount /chillipower*/* worker1


Note in the above, the url to the glassfish context would be reached using where in this instance the trailing / is important.

Load and configure the module (e.g. place this in /etc/httpd/conf.d/mod_jk.conf)

(all *.conf files are loaded by httpd.conf (before any virtual hosts etc) from the /conf.d directory in typical setups, so we can add a new mod_jk.conf and it will be loaded automatically)

LoadModule jk_module /etc/httpd/modules/
JkWorkersFile /etc/httpd/conf.d/
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send all jsp requests to GlassFish
JkMount /*.jsp worker1
# Send all glassfish-test requests to GlassFish
JkMount /chillipower/* worker1

Add file to configure the ajp worker, /etc/httpd/conf.d/

# Define 1 real worker using ajp13
# Set properties for worker1 (ajp13)

Glashfish setup:

Download Apace Tomcat 5.5.16 ->

copy the tomcat-ajp.jar to the glassfish lib folder. e.g.

cp $CATALINA_HOME/server/lib/tomcat-ajp.jar

Also, download and copy the commons logging and commons modeller jar files to $GLASSFISH_HOME/lib

Commons logger -> commons-logging-1.1.1.jar from

Commons modeler -> commons-modeler-2.0.1.jar from

Restart Glassfish...



1 comment:

FSGn1oJlmMYsyZmjGNLzWqk0g2OM said...


I'm very interested in how to set this up with Glassfish V3. Looking forward to a how-to for this.

Rgrds, OliBlogger