Apache mod_jk Setting for Tomcat - workers.properties
You are pretty close on your config, there are just a few things that are off.
First, AJP does not run over port 8080, by default it runs over port 8009. It's a different connector. You can verify which port AJP is setup for by looking at your server.xml
file for a line that looks like this:
<Connector port="8009" redirectPort="8443" protocol="AJP/1.3"/>
So you'll want to change your worker.ajp13.port=8080
directive to worker.ajp13.port=8009
Secondly, your httpd.conf is a bit off:
JkAutoAlias <path_to_tomcat>/webapps
JkMount /<your_webapp>/*.jsp ajp13
The Tomcat connector docs explain JKAutoAlias very well:
Automatically Alias webapp context directories into the Apache document space. Care should be taken to ensure that only static content is served via httpd as a result of using this directive. Any static content served by httpd will bypass any security constraints defined in the application's web.xml. For inheritance rules, see: JkMountCopy. There is no default value.
Related videos on Youtube
sissonb
Updated on September 18, 2022Comments
-
sissonb over 1 year
I am trying to direct files with
.jsp
extensions to tomcat. Otherwise I want apache to serve the file directly (no tomcat). Currently I have a test.jsp which is supposed to create an HTML page with the current date in the body. Instead when I go to that.jsp
I see the JK Status Manager. Themod_jk.logs
only show,init_jk::mod_jk.c (3365): mod_jk/1.2.35 initialized
.I have tomcat and apache setup on my server. Apache runs on 80 and tomcat runs on 8080. localhost:8080 show the tomcat welcome page. I downloaded
tomcat-connectors-1.2.35-windows-i386-httpd-2.2.x
and copied themod_jk.so
toC:\apache\modules
.Then I added
LoadModule jk_module modules/mod_jk.so
to myhttpd.conf
. I restart apache and the module loads just fine.Next I downloaded the mod_jk source to get the
workers.properties
file. I copyworkers.properties
toC:\apache\confg
. Then I added this user,workers.tomcat_home="C:/Program Files/Apache Software Foundation/Tomcat 7.0" workers.java_home="C:/Program Files/Java/jdk1.7.0_03" worker.list=ajp13 worker.ajp13.port=8080 worker.ajp13.host=localhost worker.ajp13.type=ajp13 worker.ajp13.socket_timeout=10
When I try to use the ajp13 user in my httpd.conf I get the following error in my
mod_jk.log
,[Wed Mar 28 13:08:51 2012] [2196:4100] [info] ajp_connection_tcp_get_message::jk_ajp_common.c (1258): (ajp13) can't receive the response header message from tomcat, network problems or tomcat (127.0.0.1:8080) is down (errno=60) [Wed Mar 28 13:08:51 2012] [2196:4100] [error] ajp_get_reply::jk_ajp_common.c (2117): (ajp13) Tomcat is down or refused connection. No response has been sent to the client (yet) [Wed Mar 28 13:08:51 2012] [2196:4100] [info] ajp_service::jk_ajp_common.c (2614): (ajp13) sending request to tomcat failed (recoverable), (attempt=1)
Next I update my httpd.conf with,
JkWorkersFile C:/apache/conf/workers.properties JkLogFile C:/apache/logs/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
Also I added
JkMount /*.jsp jk-status
to my virtual host like this,<VirtualHost 192.168.5.250:80> JkMount /*.jsp jk-status #JkMount /*.jsp ajp13 ServerName bgsisson.com ServerAlias www.bgsisson.com DocumentRoot C:/www/resume </VirtualHost>
I think i need to include a
uriworkermap.properties
file, but this is where I am getting stuck.I have put up a test .jsp at bgsisson.com/test.jsp It shows the JK Status Manager when I use
JkMount /*.jsp jk-status
and 502 Bad Gateway when I useJkMount /*.jsp ajp13
test.jsp
<%-- use the 'taglib' directive to make the JSTL 1.0 core tags available; use the uri "http://java.sun.com/jsp/jstl/core" for JSTL 1.1 --%> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%-- use the 'jsp:useBean' standard action to create the Date object; the object is set as an attribute in page scope --%> <jsp:useBean id="date" class="java.util.Date" /> <html> <head><title>First JSP</title></head> <body> <h2>Here is today's date</h2> <c:out value="${date}" /> </body> </html>
-
Jason Huntley about 12 yearsSorry, but it's still not clear what exactly you're asking. You want to know the next step? You're encountering an error? Specific error at startup? Can you provide the log section with error? IMHO, mod_proxy_ajp is much easier to configure and work with than mod_jk.
-
sissonb about 12 years@JasonHuntley Sorry it's not clear. I'll update the first part of my question to explain that better. Part of the reason I want to use mod_proxy is to learn all its complexities
-
-
sissonb about 12 yearsah great! didn't look at the server.xml before. thanks for the info. getting a 404 now, but I'll figure that out in a sec.