In this article we would show you how to configure mod_jk so that one can access multiple applications using single Apache in front of JBoss application servers we would be using AS6. Many companies run n-number of applications and they might be using different Apache webservers for each applications to deal with it, hence hope this article would help you guys so that you can work with a single Apache having mod_jk to access multiple applications.

Here we would be taking the below examples in which we have a two different applications and one having a different context which would cover a huge ground for a combination of applications used by companies.

Examples

* App1 should work with url: http://abc.com/test
* App2 should work with url: http://abc.com
* App3 should work with url: http://xyz.com

Steps to configure mod_jk to access multiple applications

1. In “worker.properties” file would have the following entries

worker.list=App1,App2,App3

# Define App1
worker.App1.port=8009
worker.App1.host=localhost
worker.App1.type=ajp13
worker.App1.lbfactor=1

# Define App2
worker.App2.port=8109
worker.App2.host=localhost
worker.App2.type=ajp13
worker.App2.lbfactor=1

# Define App3
worker.App3.port=8209
worker.App3.host=localhost
worker.App3.type=ajp13
worker.App3.lbfactor=1

2. In “httpd.conf” file following should be the entries

NameVirtualHost *.80 

<VirtualHost *:80>
    ServerName abc.com
    DocumentRoot "/etc/httpd/www/html"
    DirectoryIndex home.html
    ErrorLog "/etc/httpd/conf/abc-error_log"
    CustomLog "/etc/httpd/conf/abc-access_log" common
    
    #Mount
    JkMount /* abc
    JkMount /abcd* abcd
</VirtualHost>

<VirtualHost *:80>
    ServerName xyz.com
    DocumentRoot "/etc/httpd/www/html"
    DirectoryIndex index.html
    ErrorLog "/etc/httpd/conf/xyz-error_log"
    CustomLog "/etc/httpd/conf/xyz-access_log" common

    #Mount
    JkMount /* xyz
</VirtualHost>

3. However to make sure that, when you hit “http://abc.com” and “http://xyz.com” URL’s the receptive applications comes up directly you should make sure that both the applications should have the following entries in there “/AppX/WEB-INF/jboss-web.xml” file

<jboss-web>
   <context-root>/</context-root>
</jboss-web>

And in there respective JBoss nodes “/NodeX/deploy/ROOT.war/WEB-INF/jboss-web.xml” file should add the following entry.
java:/jaas/jmx-console

<jboss-web>
 <security-domain>java:/jaas/jmx-console</security-domain>
 <context-root>/root</context-root>                         <!-- THIS LINE ADDED  -->
</jboss-web>

Example:
– For App-2 the JBoss Node-2 named as “node-2”
Path:
/node-2/deploy/abc.war/WEB-INF/jboss-web.xml – should have the context-root as “/”
/node-2/deploy/ROOT.war/WEB-INF/jboss-web.xml – should have context-root as “/root”

– For App-3 the JBoss Node-3 named as “node-3”
Path:
/node-3/deploy/xyz.war/WEB-INF/jboss-web.xml – should have context-root as “/”
/node-3/deploy/ROOT.war/WEB-INF/jboss-web.xml – should have context-root as “/root”

Thus now when you hit the above given URLs in the examples it would show you the respective application and that too using a single Apache in front of JBoss.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.