Configuring mod_jk with WildFly/JBoss AS 7

This tutorial contains an excerpt of the upcoming WilfFly Book which shows how to create a load balancing configuration for WildFly 8 using the older Apache Tomcat mod_jk. Although the recommended load balancing solution for clustering JBoss AS7/Wildfly is mod_cluster you should include in your administrator’s skill also the earlier Apache Tomcat mod_jk connector in some scenarios. Configuring it requires just a couple of minutes so why not trying it ?  

As first step download the latest stable Apache mod_jk connectors from
Once completed the download, move the connector to the modules folder of your Apache 2 distribution

cp $APACHE_HOME/modules

Now create a file named for example mod-jk.conf in your Apache configuration folder. This file will contain the basic mod_jk configuration including the application we are going to route from Apache to WildFly/JBossAS 7

# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/
# Where to find
JkWorkersFile conf/
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info 
# Mount your applications
# Send everything for context /myapp to worker1 (ajp13)
JkMount /myapp/* loadbalancer
JkShmFile logs/jk.shm

Notice the difference with mod_cluster where by default all applications are already mounted.

The above file needs to be included in your httpd.conf configuration:

Include conf/mod-jk.conf

Now the configuration about workers which are the single servers where calls are routed. Create a file named in your configuration foldetr:


# Define Node1
# modify the host as your host IP or DNS name.

# Define Node2
# modify the host as your host IP or DNS name.

# Load-balancing behavior

# Status worker for managing load balancer

The above configuration can be used for example on a cluster of nodes running on localhost with a port offset of 150 for the second node (hint: you can use a Domain mode configuration with the ha/full-ha profile for quickly testing this example).

Done with mod_jk, now let’s move to WildFly configuration. In the new release of the application server the built-in Web server is not anymore a fork of Tomcat project but a brand new product named Undertow that is a flexible performant web server written in java, providing both blocking and non-blocking API€™s based on NIO.
So from the Admin Console expand the Web subsystem and select HTTP. From there you will see the list of listeners (HTTP,AJP,HTTPs) which are configured. Select the AJP tab and click on “Add“.
apache tomcat mod_jk jboss wildfly apache tomcat mod_jk jboss wildfly
In the next window enter the name for the AJP listener and the Socket Binding to be used, in our case “ajp“.


apache tomcat mod_jk jboss wildfly

Next, from the “Edit” link verify that this listener is enabled by checking the “Enabled” checkbox.

apache tomcat mod_jk jboss wildfly
If you have started the server in ha domain mode you should have now both AJP listeners running with the configured port-offset

netstat -an | find "8009"

netstat -an | find "8159"

Conclusion: the major limit of mod_jk is that you have a static configuration of your cluster and that you don’t have access to server side metrics such as JVM, CPU etc. On the other hand, this connector is quite stable and has been tested for years as front-end solution for your farm of JBoss servers. One more point to consider is that all the mod_cluster goodies could not be available for example if your subsystem does not support multicast- this could be the case of a JBoss farm running on Windows Vista/7 (By the way if somebody out there ever managed to run multicast stack on this platform please mail me a row, I’ve never been able to!). In such a scenario I guess it could be worth consider using mod_jk.