//
you're reading...
Apache, Web Server

How to configure Jboss + Apache to communicate (Configure Mod_jk)

I have done this SSL configuration earlier on Apache + Tomcat but this time I needed to configuration it on Jboss. As I am new to the Jboss (basically a die hard tomcat guy) I thought I will have to do some tweaking at Jboss level. However I found out that configurations are almost similar at both the cases
So what all we need to do is that we have to first let Jboss and Apache communicate to each other and then let Apache take care of the security.

So in the first part we will deal with configuration for Apache+Jboss communication

1. Download and install Apache on your system.
2. Then you have to load the mod_jk module in your system. You need to download and copy mod_jk.so binary into your apache/modules folder. Then uncomment  load module mod_jk.so lines in httpd.conf file in conf folder.
3. Include a mod_jk.conf file in httpd.conf , the contents of mod_jk .conf should look like

# 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
# Notes:
# 1) Changed from +ForwardURICompat.
# 2) For mod_rewrite compatibility, use +ForwardURIProxy (default since 1.2.24)
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat “%w %V %T”
# Mount your applications
JkMount /__application__/* node1
# Let Apache serve the images
#JkUnMount /__application__/images/* node1

# 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/*=node1
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
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile run/jk.shm
# Add jkstatus for managing runtime data

JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1

Let me explain few key points in the above lines
You should define a workers .properties file in which you have to define the tomcat or jboss instance which will handle the request forwarded from apache .
So we define the port , server and type like this in workers file.
# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=node1,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.prepost_timeout=10000 #Not required if using ping_mode=A
worker.node1.connect_timeout=10000 #Not required if using ping_mode=A
worker.node1.ping_mode=A #As of mod_jk 1.2.27
# worker.node1.connection_pool_size=10 (1)

# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1

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

then you have to define the applications or the servlet contexts which you are going to access through the nodes which you have defined in worker file. So create a uriworkermap.properties file reference to which you have already given in your mod_jk .conf file.

Mount the Servlet context to the ajp13 worker
/jmx-console=node1
/jmx-console/*=node1
/web-console=node1
/web-console/*=node1
/ APP_Name /*=node1

Now we have to got to your jboss or tomcat instance and enable AJP port. You may comment your localhost:8080 settings if you do not want it to get accessed directly.
I am pasting the jboss snippet here although you may already know .

<Connector protocol=”AJP/1.3″ port=”8009″ address=”${jboss.bind.address}”

redirectPort=”8443″ />

<Engine name=”jboss.web” defaultHost=”localhost”  jvmRoute=”node1″>

That is all what is required to configure Apache+jboss to communicate .
You may hit http://localhost/<APP_Name > to check instead of 8080 port.

I hope you will be able to set up your server  with the configuration I have written above. Now in the next part I will let you know how to set up  SSL for this.

Advertisements

About Gaurav Mutreja

Well I think a lot !! Now I would like to speak a bit!

Discussion

4 thoughts on “How to configure Jboss + Apache to communicate (Configure Mod_jk)

  1. Hi Gaurav, have you implemented Apache with Tomcat. I have implemented SSL for Apache, I’m implemeting Apache with Tomcat, but when i start Apache2.2 it doesnt start, it gives me error. In httpd.conf i have added two lines
    LoadModule jk_module modules/mod_jk.so
    Include “C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/jk/mod_jk.conf”

    and mod_jk.conf is LoadModule C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so
    JkWorkersFile C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/jk/workers.properties
    JkLogFile C:/Program Files/Apache Software Foundation/Apache2.2/logs/jk.log
    JkLogLevel info
    JkLogStampFormat “[%a %b %d %H:%M:%S %Y]“
    JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
    JkRequestLogFormat “%w %V %T”
    JkMount /examples ajp13
    JkMount /examples/* ajp13

    and workers.properties file is
    workers.tomcat_home=”C:/Program Files/Apache Software Foundation/Tomcat 6.0″

    workers.java_home=”C:/Program Files/Java/jdk1.6.0_13″

    ps=\

    # Define worker ‘worker1’
    worker.list=worker1

    # Set properties for worker ‘example’ (ajp13)
    worker.worker1.type=ajp13
    worker.worker1.host=localhost
    worker.worker1.port=8009

    worker.worker1.cachesize=10
    worker.worker1.cache_timeout=600
    worker.worker1.socket_keepalive=1
    worker.worker1.recycle_timeout=300

    and some changes in server.xml of Tomcat

    Any help will be appriciated…

    Posted by jatinder | May 10, 2011, 11:17 am
  2. Hi jatinder,

    The server is not staring it means there is some configuration error and not apache+tomcat communication error.

    What I see is that you have included LoadModule jk_module modules/mod_jk.so twice once in httpd.conf and another in mod_jk conf file.May be that is causing the problem.

    Hope it solves your problem,let me know if you face any other problem and yes do not forget to check logs for mod_jk and apache both.

    Posted by Gaurav Mutreja | May 10, 2011, 12:19 pm
  3. Oh my goodness! Incredible article dude! Many thanks, However I am going through issues with your RSS.
    I don’t understand why I cannot join it. Is there anybody else getting identical RSS problems? Anyone who knows the solution will you kindly respond? Thanks!!

    Posted by Jonathan | May 2, 2013, 3:48 am
  4. Hurrah! Finally I got a blog from where I can truly obtain valuable
    facts regarding my study and knowledge.

    Posted by quality commercial pest control | July 23, 2013, 2:08 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: