Wildfly is also able to handle front-end requests with the load-balancer profile. Check this tutorial to learn more: Configuring High Availability with WildFly
The following picture describes an high level view of the communication between the httpd server and a set of JBoss nodes:
Installing mod_cluster
1) Download the Java Bundle package which contains the Service Archive (.sar) to be deployed on JBoss
2) Download the binaries for your platform which contains a built-in httpd server and its modules (including mod_cluster).
1. Installing Java Bundles
From the bundle tar.gz, copy the file mod-cluster.sar in the “deploy/cluster” folder of your “all” configuration:
2. Installing Mod_cluster Binaries
You have to copy the following modules to your Apache Web server installation:
- mod_proxy.so
- mod_proxy_ajp.so
- mod_slotmem.so
- mod_manager.so
- mod_proxy_cluster.so
- mod_advertise.so
3. Update JBoss AS Configuration
Now open the file server.xml which contains the embedded Web Server configuration and is located in the deploy/jbossweb.sar/ folder and add the following line at the same level of other Listeners:
<Listener className="org.jboss.web.tomcat.service.deployers.MicrocontainerIntegrationLifecycleListener" delegateBeanName="ModClusterService"/>
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="node01">
Just add the following dependency to the WebServer bean (approx line 16)
<depends>ModClusterService</depends>
4. Update Apache Web Server configuration
In order to enable mod_cluster, the following modules need to be enabled:
LoadModule proxy_module /modules/mod_proxy.so LoadModule proxy_ajp_module /modules/mod_proxy_ajp.so LoadModule slotmem_module /modules/mod_slotmem.so LoadModule manager_module /modules/mod_manager.so LoadModule proxy_cluster_module /modules/mod_proxy_cluster.so LoadModule advertise_module /modules/mod_advertise.so
Then, add this configuration to the bottom of your Apache’s httpd.conf file:
Listen 192.168.1.0:6666 <VirtualHost 192.168.1.0:6666> <Directory /> Order deny,allow Deny from all Allow from 192.168.1. </Directory> KeepAliveTimeout 60 MaxKeepAliveRequests 0 ManagerBalancerName mycluster AdvertiseFrequency 5 </VirtualHost>
Here we assume that your Apache listen to the IP Address 192.168.1.0 and accepts requests on port 6666.
Now the configuration is complete. Restart Apache and start a set of JBoss nodes:
JBoss AS 4/5/6
run.sh -c all -b 192.168.1.10
JBoss AS 7
standalone.sh -c standalone-ha.xml -b 192.168.1.10
Verify that both Apache and JBoss serve correctly web pages:
should serve Apache home page. (“It works!”)
Now deploy a sample Web application to JBoss cluster, for example MyWebApp context:
http://192.168.1.0:6666/MyWebApp
As you can see, mod cluster automatically configures a context for all your Web applications, unless you have explicitly excluded it in mod_cluster.sar/META-INF/mod-cluster-jboss-beans.xml file. (Look for the property excludedContexts)