0% found this document useful (0 votes)
18 views

Configuring Apache in front of JBoss Application Server

This document provides a step-by-step guide for configuring Apache HTTP server as a front-end to JBoss Application Server using mod_jk or mod_proxy. It outlines the advantages of using Apache for serving static content, load balancing, and security, and details the necessary configurations for both methods. The guide is tailored for Windows systems but notes that the steps are similar for Linux systems.

Uploaded by

j. koteswarao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Configuring Apache in front of JBoss Application Server

This document provides a step-by-step guide for configuring Apache HTTP server as a front-end to JBoss Application Server using mod_jk or mod_proxy. It outlines the advantages of using Apache for serving static content, load balancing, and security, and details the necessary configurations for both methods. The guide is tailored for Windows systems but notes that the steps are similar for Linux systems.

Uploaded by

j. koteswarao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Configuring Apache in front of JBoss Application Server Using mod_jk

Introduction
Apache HTTP server is a highly reliable and proven open source/free web server. It is under
development for over 15 years and is used extensively to host web sites. Since Apache is very
popular and the source code is available, security experts are always looking for any
vulnerability. This makes it one of the most secure web servers.
JBoss AS is a popular open source J2EE application server widely used for deploying web
applications. JBoss is powered by Tomcat servlet container which can also work as a Web server.
However in many production deployments, Apache is configured as the web server in front of the
JBoss server. This is due to the extensive set of features/deployment options offered by Apache
HTTP server.
This article provides a step by step guide on configuring Apache HTTP server as the Web server
in front of the JBoss application server. This guide is written for Microsoft Windows systems
(Windows XP, Windows 7, Windows Server 2008 etc.). However the steps mentioned are similar
on a Linux based system.

Why to Configure Apache HTTP server in front of JBoss Application Server?


Application servers are good at hosting Web applications, but they are not as good when it comes
to serving static content, providing load balancing, URL rewriting, security etc. Following are
some of the advantages of using Apache HTTP web server in front of an application server such
as JBoss.
 Apache is a high performance and highly secure Web server with advanced features. It is a
proven server and as of 2010, it is run on over 100 million servers.
 Apache comes with a lot of extension modules providing essential hosting features such as
logging, virtual hosting, URL rewriting etc.
 Apache can be used as a load balancer distributing load across multiple JBoss instances. Mod_jk
connector supports advanced load balancing configurations.
 A single Apache server instance can serve multiple domains using virtual hosting and at the
same time they can all be serviced by different JBoss servers. This ensures process isolation for
web applications hosted in each domain.
Apache to JBoss Request Routing – How It Works?
There are two different ways of configuring Apache to JBoss routing. One is to use the Tomcat
connector available for Apache called the mod_jk connector. This is an Apache module
specifically written by Tomcat team. This module routes the Apache to JBoss request via the AJP
(Apache Jserv Protocol).
Second method is to use an Apache module called mod_proxy. This proxy can either use HTTP or
AJP for routing request from Apache to JBoss. The advantage of mod_proxy is that it is available
as a built in module in Apache 2.x versions.
When it comes to load balancing and
failure detection, mod_jk is better
than mod_proxy. The only
disadvantage is the need to
separately deploy mod_jk module.
In either case, if the Apache
connector is using AJP protocol, the
AJP protocol listener must be
enabled on the JBoss server. By
default JBoss binds AJP service to the
port 8009. Whenever a request is
received by Apache, it looks at the
AJP module configuration
file(workers.properties) and if the
request is intended for the JBoss
server, the request is routed through AJP protocol to the port 8009(Please see the diagram
above).

Configuring Apache to JBoss HTTP Request Routing Using Mod_Jk


To configure mod_jk integration, either download mod_jk source code or mod_jk binary for your
platform from here. Copy the compiled or downloaded module to the modules directory of your
Apache installation.
For windows : https://www.apachelounge.com/download/
https://www.apachelounge.com/download/VS16/modules/mod_jk-1.2.48-win64-VS16.zip

Now create a new file named mod_jk.conf inside apache/conf folder. Add the following content
to this file. Please ensure that the name of the module (mod_jk.so) is changed to the actual
module file copied to the modules directory.

LoadModule jk_module modules/mod_jk.so


JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /sample/* worker1

The directive JkMount here ensures that all HTTP requests with context /sample/ are forwarded to
the worker1 application server configured in workers.properties (see below).
Open httpd.conf in apache/conf folder and add the following line at the end of the file. This
enables the mod_jk.conf file as an extension to the default configuration file.

Include conf/mod_jk.conf

Create a new file workers.properties inside apache/conf folder. Add the following content to the
file. Note that the name of the JBoss node (worker1) corresponds to the JkMount configuration in
mod_jk.conf file. The host in this case is given as localhost since I have the JBoss running on the
same machine. In actual deployments replace localhost with the ip address/host name of the
JBoss machine.
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

The above configuration indicates that there is a single application server machine available for
handling requests in the localhost and it is available through AJP protocol via port 8009.
Restart apache and JBoss and access your Web application through Apache server using this URL
– http://localhost:80/App1.

1. On the JBoss side, you have to add the AJP connector, which is not inserted by default:

<subsystem xmlns="urn:jboss:domain:web:1.1"><connector name="http"


protocol="HTTP/1.1" socket-binding="http" scheme="http"/>

<connector name="AJP" protocol="AJP/1.3" scheme="http" socket-


binding="ajp" />
<virtual-server name="localhost">
<alias name="example.com"/>
</virtual-server>
</subsystem>

Configuring Apache to JBoss HTTP Request Routing Using Mod_Proxy

1. Open httpd.conf file and search for Mod_proxy


2. Uncomment the below two lines.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

3. Add the below lines at end of the httpd.conf file


ProxyPreserveHost On
ProxyPass /<ContextPath> http://hostname:port/<ContextPath>
ProxyPassReverse /<ContextPath> http://hostname:port/<ContextPath>
4. Restart Apache Server and access the URL- http://localhost:80/

You might also like