There was a problem loading the comments.

User Guide - JBoss deployment using mod_jk and mod_proxy_ajp

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Applicable Plans: Standard Max VPS, All Advanced VPS, All Premier VPS (not Plesk or cPanel)

User Guide – JBoss deployment with mod_jk and mod_proxy_ajp

JBoss Application Server is a full featured, royalty free, Open Source, Sun certified J2EE application server. For more information on the providers of this software, please visit http://www.jboss.org. The JBoss server package that is available to you in your eApps VPS service includes the embedded Tomcat application server, which is used to serve JSP pages and Java servlets. For more information on this open source, royalty free software please see The Apache Software Foundation's web site at http://jakarta.apache.org/tomcat/index.html.

The eApps Hosting service is designed to make it easy to use JBoss for serving J2EE applications in your Virtual Private Server (VPS). This User Guide is not intended as a reference source for JBoss. See the Links to other information at the end of this document if you need detailed information about JBoss.

The purpose of this User Guide is to explain how to configure JBoss in your VPS on the eApps Hosting service using mod_jk or mod_proxy_ajp. Instructions on how to deploy JBoss applications in Standalone mode are found here.

The information in this User Guide is based on the assumption that you have already read the JBoss User Guide – Installation and Tuning, and have met all the Prerequisites. If you have not read that User Guide, please do so now. Reading and following that User Guide is the key to success with the information in this User Guide.

Information covered the the Installation and Tuning User Guide, such as how to deploy your applications to the VPS and how to configure JBoss are not covered in this User Guide.

If you follow the guidelines explained in this User Guide you will remain safely inside the eApps Support envelope. If you choose to use a custom configuration that is outside of the guidelines contained in this document, you may be subject to service fees if you need assistance from the eApps Support department.

JBoss is not available in the Standard and Standard Plus plans due to memory requirements. The Standard Max plan does have enough memory to run JBoss and serves as our entry level plan for JBoss users. However, it is important that you select a plan that has enough memory for your application during peak usage.

If you do not need the advanced features of JBoss, and just need support for JSP and Servlets, we recommend that you uninstall JBoss and install Tomcat instead, as Tomcat uses less resources and is not as complex as JBoss to configure and use.

JBoss is a very complex and powerful application that is intended for advanced users. Before deploying your applications with JBoss, make sure that you really need all the complexity that JBoss requires and provides.

Apache as a front end to JBoss using mod_jk
mod_jk syntax overview 
Examples using mod_jk 

Apache as a front end to JBoss using mod_proxy_ajp (CentOS 5 only) 
Examples using mod_proxy_ajp 

Links to other information


Apache as a front end to JBoss using mod_jk

mod_jk is used to forward requests from Apache to JBoss. Apache runs securely on port 80, and JBoss runs securely on port 8080. This means that by default, the URL of your application will either be http://example.com:8080 or http://example.com:8080/webapp. With mod_jk, you are able to run JBoss securely on port 8080 and have Apache forward requests to JBoss. This eliminates the 8080 from the URL.

As a reminder, make sure that mod_jk is installed. You can verify this from the Control Panel, System Tab, All Applications.

In this User Guide, remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.

Due to the complexity of JBoss, it is impossible to give exact instructions for some of these examples, especially in the case of the jboss-web.xml and application.xml files! Keep in mind that these are only examples; you will need to work with your JBoss developer or consult the official JBoss documentation to determine the exact settings for some of these files.

When mod_jk is installed, default directives are created in /etc/httpd/conf.d/mod_jk.conf or in /etc/httpd/conf/httpd.conf depending on the version of mod_jk installed. These are the default mod_jk directives:

JkMount /*.jsp ajp13
JkMount /*.do ajp13
JkMount /manager* ajp13 ## Tomcat manager application
JkMount /admin* ajp13 ## Tomcat admin application
JkMount /web-console* ajp13 ##JBoss web-console application


You must also specify mod_jk directives for your application in the Custom Settings tab for each website you create that uses JBoss. Custom Settings is found in the Website Settings link for each site listed in the Site Tab of the Control Panel. Click on Edit to add your mod_jk directives, and then Update to save them.

mod_jk also offers no-jk directives, which allow requests for certain applications, such as Open Webmail or Awstats to bypass JBoss so they can be served directly by Apache. The no-jk directives are also added to the Custom Settings tab for each site. Examples of no-jk directives are given as part of the mod_jk examples.

NOTE – if you add mod_jk directives for your application manually to the /etc/httpd/httpd.conf file, your changes WILL be over written by the Control Panel. This is a function of how the Control Panel software works, and cannot be changed. Please add all mod_jk directives for your applications to the Custom Settings tab for your site.

mod_jk syntax overview

The standard format for a mod_jk directive is:
JkMount /servlet/* ajp13
  • JkMount – this is the JkMount directive that calls mod_jk
  • /servlet/* - this is the regular expression(regex) that is matched in the referring URL and is passed to the servlet container. Typically, this is the only part of a JkMount directive you will change
  • ajp13 – this is the internal handler that will receive the request. Unless you are a very advanced user you will never change this part of the directive. eApps only supports the ajp13 handler.
The above directive will pass all URLs with a suffix of /servlet/ to the ajp13 handler and the request will be handled by JBoss. A URL with a suffix of /mail will still be handled by Apache.

Examples using mod_jk

Deployment with JBoss serving JSP and Servlets using a WAR file at example.com/mywebapp,  Apache serving all other content

This deployment example assumes you are serving your JBoss application from the default/deploy directory, using a WAR file and calling the application directly.

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • jboss-web.xml - To associate your WAR file with a specific host you must add lines like the example below in your application WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<context-root>mywebapp</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_jk directives - in this example Apache will serve all applications provided by eApps but forward request to /mywebapp to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
JkMount /mywebapp* ajp13

Deployment with JBoss serving JSP and Servlets using a WAR file at example.com, Apache serving all other content 

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.
This deployment example assumes you are serving your JBoss application from the default/deploy directory, using a WAR file and the root context (example.com).

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
  • server.xml - Add the following host just below the last closing host tag (</Host>) in your /opt/jbossX/server/default/deploy/jboss-web.deployer/server.xml file. This will serve your application at http://example.com and http://www.example.com.

<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • jboss-web.xml - To associate your WAR file with a specific host you must add lines like the example below in your application WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.

<jboss-web>
<context-root>/</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_jk directives - in this example Apache will serve all applications provided by eApps but forward all other requests to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
jkMount /* ajp13
# Directives to enable Apache to continue serving applications dependent on it.
SetEnvIf Request_URI "/webmail*" no-jk
SetEnvIf Request_URI "/mail*" no-jk
SetEnvIf Request_URI "/awstats*" no-jk
SetEnvIf Request_URI "/myadmin*" no-jk
SetEnvIf Request_URI "/pgadmin*" no-jk
SetEnvIf Request_URI "/cgi-bin*" no-jk
SetEnvIf Request_URI "/openwebmail*" no-jk
SetEnvIf Request_URI "/joomla*" no-jk
SetEnvIf Request_URI "/wordpress*" no-jk
SetEnvIf Request_URI "/webmail*" no-jk
SetEnvIf Request_URI "/drupal*" no-jk
SetEnvIf Request_URI "/mailman*" no-jk
SetEnvIf Request_URI "/spamassassin*" no-jk

Deployment with JBoss serving JSP and Servlets using an EAR file at example.com/mywebapp, Apache serving all other content

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.
This deployment example assumes you are serving your JBoss application from the default/deploy directory, using an EAR file and calling the application directly.

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • application.xml - Applications packaged in an EAR must also define the context in the applications application.xml file. For our example mywebapp we should have lines similar to what is below in this file.
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>mywebapp</display-name>
<module>
<ejb>mywebapp-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>mywebapp.war</web-uri>
<context-root>mywebapp</context-root>
</web>
</module>
</application>

  • jboss-web.xml - To associate your WAR file inside your EAR with a specific host you must add lines like the example below in your mywebapp.war WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<context-root>mywebapp</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_jk directives - in this example Apache will serve all applications provided by eApps but forward the request for /mywebapp to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
JkMount /mywebapp* ajp13

Deployment with JBoss serving JSP and Servlets using an EAR file at example.com, Apache serving all other content

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.
This deployment example assumes you are serving your JBoss application from the default/deploy directory, using an EAR file and the root context (example.com).

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
  • server.xml - Add the following host just below the last closing host tag (</Host>) in your /opt/jbossX/server/default/deploy/jboss-web.deployer/server.xml file. This will serve your application at http://example.com and http://www.example.com.
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • application.xml - Applications packaged in an EAR must also define the context in the applications application.xml file. For our example we should have lines similar to what is below in this file.
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>mywebapp</display-name>
<module>
<ejb>mywebapp-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>mywebapp.war</web-uri>
<context-root>/</context-root>
</web>
</module>
</application>

  • jboss-web.xml - To associate your WAR file inside your EAR with a specific host you must add lines like the example below in your mywebapp.war WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<!-- Root Contest for virtual Host --->
<context-root>/</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_jk directives - in this example Apache will serve all applications provided by eApps but forward requests to / to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
JkMount /* ajp13
# Directives to enable Apache to continue serving applications dependent on it.
SetEnvIf Request_URI "/webmail*" no-jk
SetEnvIf Request_URI "/mail*" no-jk
SetEnvIf Request_URI "/awstats*" no-jk
SetEnvIf Request_URI "/myadmin*" no-jk
SetEnvIf Request_URI "/pgadmin*" no-jk
SetEnvIf Request_URI "/cgi-bin*" no-jk
SetEnvIf Request_URI "/openwebmail*" no-jk
SetEnvIf Request_URI "/joomla*" no-jk
SetEnvIf Request_URI "/wordpress*" no-jk
SetEnvIf Request_URI "/webmail*" no-jk
SetEnvIf Request_URI "/drupal*" no-jk
SetEnvIf Request_URI "/mailman*" no-jk
SetEnvIf Request_URI "/spamassassin*" no-jk


Apache as a front end to JBoss using mod_proxy_ajp (CentOS 5 only)

mod_proxy_ajp is an extension of the mod_proxy module that is available in Apache 2.2. The required modules are installed automatically on an eApps VPS running the CentOS 5 operating system or higher version. As with mod_jk, the mod_proxy_ajp directives must be specified in Custom Settings for each site.

Due to the complexity of JBoss, it is impossible to give exact instructions for some of these examples, especially in the case of the jboss-web.xml and application.xml files! Keep in mind that these are only examples; you will need to work with your JBoss developer or consult the official JBoss documentation to determine the exact settings for some of these files.

In this User Guide, remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.

Examples using mod_proxy_ajp

Deployment with JBoss serving JSP and Servlets using a WAR file at example.com/mywebapp, Apache serving all other content

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.

This deployment example assumes you are serving your JBoss application from the default/deploy directory, using a WAR file and calling the application directly.

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • jboss-web.xml - To associate your WAR file with a specific host you must add lines like the example below in your application WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<context-root>mywebapp</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_proxy_ajp directives- in this example Apache will serve all applications provided by eApps but forward the request for /mywebapp to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
ProxyPass /mywebapp ajp://localhost:8009/mywebapp

Deployment with JBoss serving JSP and Servlets using a WAR file at example.com, Apache serving all other content

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.

This deployment example assumes you are serving your JBoss application from the default/deploy directory, using a WAR file and the root context (example.com).

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
  • server.xml - Add the following host just below the last closing host tag (</Host>) in your /opt/jbossX/server/default/deploy/jboss-web.deployer/server.xml file. This will serve your application at http://example.com and http://www.example.com.
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • jboss-web.xml - To associate your WAR file with a specific host you must add lines like the example below in your application WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<context-root>/</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_proxy_ajp directives - in this example Apache will serve all applications provided by eApps but forward the request for / to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
# Directives for your application
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
# Directives for eApps applications dependent on Apache
ProxyPass /webmail !
ProxyPass /mail !
ProxyPass /joomla !
ProxyPass /awstats !
ProxyPass /myadmin !
ProxyPass /cgi-bin !
ProxyPass /pgadmin !
ProxyPass /openwebmail !

Deployment with JBoss serving JSP and Servlets using an EAR file at example.com/mywebapp, Apache serving all other content

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.
This deployment example assumes you are serving your JBoss application from the default/deploy directory, using an EAR file and calling the application directly.

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • application.xml - Applications packaged in an EAR must also define the context in the applications application.xml file. For our example we should have lines similar to what is below in this file
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>mywebapp</display-name>
<module>
<ejb>mywebapp-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>mywebapp.war</web-uri>
<context-root>mywebapp</context-root>
</web>
</module>
</application>

  • jboss-web.xml - To associate your WAR file with a specific host you must add lines like the example below in your application WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<context-root>mywebapp</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_proxy_ajp directives- in this example Apache will serve all applications provided by eApps but forward the request for /mywebapp to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
ProxyPass /mywebapp ajp://localhost:8009/
ProxyPassReverse /mywebapp ajp://localhost:8009/

Deployment with JBoss serving JSP and Servlets using an EAR file at example.com, Apache serving all other content

Remember to substitute JBossX or jbossX with your version of JBoss, and example.com with your actual domain name.
This deployment example assumes you are serving your JBoss application from the default/deploy directory, using an EAR file and the root context (example.com).

Note for JBoss 5 users - the server.xml file is now located at /opt/jboss5/server/default/deploy/jbossweb.sar/
  • server.xml - Add the following host just below the last closing host tag (</Host>) in your /opt/jbossX/server/default/deploy/jboss-web.deployer/server.xml file. This will serve your application at http://example.com and http://www.example.com.
<Host name="example.com"
autoDeploy="false" deployOnStartup="false" deployXML="false">
<Alias>www.example.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="example.com" suffix=".log" pattern="common"
directory="${jboss.server.home.dir}/log"/>
<DefaultContext cookies="true" crossContext="true" override="true"/>
</Host>

  • application.xml - Applications packaged in an EAR must also define the context in the applications application.xml file. For our example we should have lines similar to what is below in this file
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>mywebapp</display-name>
<module>
<ejb>mywebapp-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>mywebapp.war</web-uri>
<context-root>/</context-root>
</web>
</module>
</application>

  • jboss-web.xml - To associate your WAR file with a specific host you must add lines like the example below in your application WEB-INF/jboss-web.xml file. In this case we are associating a way with the example.com host.
<jboss-web>
<context-root>/</context-root>
<virtual-host>example.com</virtual-host>
</jboss-web>

  • mod_proxy_ajp directives - in this example Apache will serve all applications provided by eApps but forward the request for / to JBoss. Add the following to the Custom Settings tab in Website Settings for the example.com site
# Directives for eApps applications dependent on Apache
ProxyPass /webmail !
ProxyPass /mail !
ProxyPass /joomla !
ProxyPass /awstats !
ProxyPass /myadmin !
ProxyPass /cgi-bin !
ProxyPass /pgadmin !
ProxyPass /openwebmail !
# Directives for your application
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/


Links to other information

JBoss Home Page: http://jboss.org/
JBoss wiki: http://www.jboss.org/wiki/Wiki.jsp
Apache 2.2 Documentation: http://httpd.apache.org/docs/2.2/
Mod_jk Home Page: http://tomcat.apache.org/connectors-doc/
eApps mod_proxy User Guide: http://support.eapps.com/hsp/mod_proxy_balancer
eApps Apache User Guide: http://support.eapps.com/apache

Share via
Did you find this article useful?  

Related Articles


On-Premise Help Desk Software by SupportPal

Categories

© Cloudscale365