-   Linux - Server (
-   -   How to connect Apache to Tomcat? (

Felipe 05-01-2011 12:57 PM

How to connect Apache to Tomcat?

I'm configuring a web server using Apache and Tomcat. I use Apache 2 and various instances of Tomcat5 and Tomcat6.
I try that Apache serves the static data and tomcat the dynamic (Apache receives all requests, sending tomcat only the dynamic)

I see that Apache and Tomcat can be connected using http or ajp Can any tell me:
- What connector should I use: ajp, http,...?
- How can I say Apache to serve the static data and Tomcat the dynamic?
Due to I have many instances of Tomcat, connectins http and https, https with client certificates, and due to the port configuration:
- Is there any way to configure Apache-tomcat without the use of ports in tomcat (a differect connector)?

An easy sample would be appreciated.


gilead 05-01-2011 07:19 PM

I use mod_jk (ajp) to connect Apache and Tomcat. I made changes to the Apache httpd.conf file (you probably won't need the same set and there are others):

LoadModule jk_module modules/
JkWorkersFile "/usr/local/apache2/conf/extra/"
JkLogFile "/var/log/httpd/mod_jk.log"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T

The file contains this:


To direct URLs I use this in the virtual hosts section:

  JkMount /timesheets ajp13
  JkMount /timesheets/* ajp13
  JkMount /timesheetadmin ajp13
  JkMount /timesheetadmin/* ajp13
  JkMount /testingdb ajp13
  JkMount /testingdb/* ajp13

This info is from an old backup (I'm not at work at the moment) and I can't recall why I have the top directory as well as the wildcard, but google may help.

Felipe 05-02-2011 02:21 AM

Thank you for the information.
It's detailed and I'll look for some of the parameters.

The only question I can't see is how to say Apache to serve static data and Tomcat de dynamic.
Do I have to mount it on Apache and Tomcat? How do I do it?


gilead 05-02-2011 03:14 AM

You can put the static URLs in <Directory>, <Location> tags, etc. and the dynamic content is referenced with the JkMount directives.

All times are GMT -5. The time now is 07:11 AM.