Setup Apache to forward java (*.jsp) requests from Apache to Tomcat

11:05 AM

Requirements:
(This guide assumes the following)
Apache 2.2 and Tomcat 7.0 installed and working with defaults settings

  • Step 1: Login to the server with Apache 2.2 installed on it
  • Step 2: Down load the following file mod_jk
  • Step 3: Copy the file mod_jk.so to the following folder (%Apache root%\modules)
  • Step 4: Edit the httpd.conf file (%Apache root%\conf\httpd.conf)
  • Step 5: Add the following code to the bottom of the file

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties

JkLogFile logs/mod_jk.log

JkLogLevel error

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

JkRequestLogFormat "%w %V %T"

JKMount /*.jsp example

#example can be renamed but (worker.list=) must be updated in the workers.properites file

  • Step 6: Make a new file called workers.properties at (%Apache root%\conf) with the following code

    Icon

    Make sure to add host IP and port, and remove <> sections

# Define worker 'example'

worker.list=example # Must be same name as name at the end of JKMount in apache's httpd.conf file

# Set properties for worker 'example' (ajp13)

worker.example.type=ajp13

worker.example.host=<server IP of tomcat server, can be localhost if tomcat is installed on the same server>

worker.example.port=<port number for Tomcat AJP/1.3 connector, Default is 8009>

worker.example.cachesize=10

worker.example.cache_timeout=600

worker.example.socket_keepalive=1

worker.example.recycle_timeout=300

  • Step 7: Make a .jsp page to test
  • Step 8: Use the following code make a file called test.jsp and save (%Tomcat Root%\webapps\test)

<html>

<head>

<title>Tutorial: HelloWorld</title>

</head>

<body>

<h1>Testing Page Load from Tomcat</h1>

JSP page loading from Tomcat

</body>

</html>

Now you are done, any request for a .jsp page that comes into Apache will be served by Tomcat.

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results