Chapter 5. Integration with the Apache Web Server

Suppose you already have your main web site up and running with the Apache httpd web server. You want to get started with Tomcat, but you do not switch your entire site over. Or, you want to use Tomcat for servlets and JavaServer pages, but keep running the older server because you believe it will give better performance for static pages, binary images, and the like. There are several ways of integrating Tomcat into another web server, but they fall into a small set of general categories, in the order of increasing quality but also increasing complexity:

  • Two separate web servers connected by URLs

  • Proxying requests from Tomcat to Apache httpd

  • Proxying requests from Apache httpd to Tomcat via mod_proxy

  • Other Apache httpd connector modules, including mod_jk

The first approach—using two web servers connected by URLs—is the simplest to implement. You simply put URLs in your existing web page directory that link to Tomcat's web server port, say 8080, on the same web server machine. Or, you could make Tomcat run on port 80, and you could run Apache httpd on another hostname (e.g., the main server is Tomcat on www.example.com and Apache httpd is on httpd.example.com). You are running two full web server programs, with no real integration between them, however, to the web user it may appear as though your web site is all from one web server.

The second approach uses the built-in mod_proxy module that comes with Apache httpd. Proxies are often used ...

Get Tomcat: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.