[jboss-user] Re: Apache Webserver (2.x) with JBoss 4.0. Let Apache serve the static content while JBoss is the J2EE Container

samk at twinix.com samk at twinix.com
Wed Oct 24 09:31:10 EDT 2007


See Thread at: http://www.techienuggets.com/Detail?tx=4 Posted on behalf of a User

Hi,
i'm having problems deploying the web app using the article.
i've done all the changes suggested and also from another article it states to edit out the  <!-- A HTTP/1.1 Connector on port 8080 -->
element section and leave it as  <!-- A AJP 1.3 Connector on port 8009 -->

my question is where do i deploy the web app. i have it currently configured in a directory for Apache to serve as an exploded .war contents , do i also need to place the .war file in deploy folder of Jboss.  this is only for a single machine single jboss instance setup.

i'm acessing it as http://localhost/myapp from the apache configuration  do i need to put the port 8009 which is where the jboss AJP 1.3 connector is available?

please can you inform me how a webapp is run using the apache / jboss config?

In Response To: 

Download the connector from <a href=http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.15/>
the Apachie download site.  Select mod_jk-apache-2.0.55.so for Apache 2.0, and it works with Apache 2.0.50
and later (Remember to get the latest version. Directives like JkMountFile donÂ’t work with older versions
and this will save you a lot of grief). This binary has to be renamed to mod_jk.so and placed in your
modules directory. If you used the default installation of Apache, this directory is C:\Program Files\Apache
Group\Apache2\modules. Now we need to tell Apache about JBoss/Tomcat container. You should create a file
called mod-jk.conf in the Apache conf directory (C:\Program Files\Apache Group\Apache2\conf) and include
it into the httpd.conf directory. Alternately you could add this directly into httpd.conf file but to
include mod-jk.conf is the acceptable and preferred way. Do this by adding the following lines at the
end of the httpd.conf file: 

# Include mod_jk configuration file
Include conf/mod-jk.conf


The content of mod-jk.conf:

# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers.properties

# Where to put jk logs
JkLogFile logs/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info 

# Select the log format
JkLogStampFormat  "[%a %b %d %H:%M:%S %Y]"

# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"

# Mount your applications
JkMount /application/* loadbalancer

# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties               

# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm 

# Add jkstatus for managing runtime data
<Location /jkstatus/>
    JkMount status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>    

Now a workers.properties file needs to be created in the conf directory to tell Apachie where the servlet
container (JBoss/Tomcat) is. Here are the contents of a typical file:

# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=host1.mydomain.com 
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.local_worker=1 (1)
worker.node1.cachesize=10

# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host= host2.mydomain.com
worker.node2.type=ajp13
worker.node2.lbfactor=1
#worker.node2.local_worker=1 (1)
worker.node2.cachesize=10

# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
#worker.loadbalancer.local_worker_only=1
#worker.list=loadbalancer

# Status worker for managing load balancer
worker.status.type=status

Change host1 and host2 to the DNS name or IP address of the server (or servers) that the servlet container
is installed on. For load balancing and other detailed information look at the mod-jk documentation the
Apache website. This should work out of the box if you just change host1 and host2.

Now create uriworkermap.properties in the conf directory and populate is as follows:

# Simple worker configuration file
#

# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer


The above tells Apache to forward requests /jmx-console and /web-console to JBoss. Add your own context
references that you want forwarded to JBoss in this file.

Finally a couple of changes in the JBoss configuration: Make the changes in your model/engine, i.e.,
all/default/minimal.

1.	In C:\Program Files\jboss-4.0.2\server\default\deploy\jbossweb-tomcat55.sar\META-INF\jboss-service.xml
set the following attribute to true from false. This will allow sessions cookies to include the jvmroute
attribute in cookies 
   <attribute name="UseJK">true</attribute> 

2.	In C:\Program Files\jboss-4.0.2\server\default\deploy\jbossweb-tomcat55.sar\server.xml add the jvmroute
attribute as shown . Make sure host1 is the same host/node that you used in workers.properties. 
<Engine name="jboss.web" defaultHost="localhost" vmRoute="host1"> 

Now restart the Apache Webserver and JBoss and you should be in business.

 







More information about the jboss-user mailing list