Using Tomcat with Apache httpd

Don't run Tomcat through Apache httpd if you can avoid it

It is advisable to run Tomcat standalone, not connected through Apache httpd, because you will lose at least 50% of Tomcat's response performance by proxying all requests through an Apache httpd module first. For benchmarks and additional details on why you should run Tomcat standalone, see Tomcat: The Definitive Guide, 2nd Edition (O'Reilly).

If you decide that you must run Tomcat behind Apache httpd, we suggest using only the built-in mod_proxy module for proxying the requests to Tomcat. To use mod_proxy, search for the following lines in your Apache httpd's configuration files, and add them if they don’t already exist:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Next, add the following lines anywhere after the LoadModule lines:

ProxyPass        /tcat http://127.0.0.1:8080/
ProxyPassReverse /tcat http://127.0.0.1:8080/
ProxyVia On 

These lines tell Apache httpd to proxy all requests it receives for

/tcat*
via the HTTP protocol into Tomcat's HTTP connector running on port 8080. Make sure to restart httpd after making the configuration change, and inspect the error log for any problems before proceeding.

In Tomcat's

server.xml
file, make sure that there is a port 8080
<Connector>
element that is enabled in the configuration. Also, you probably want to set your Connector's
proxyHost
and
proxyPort
attributes to values that match your Apache httpd web server's host name and port number, so that the responses from Tomcat appear to be coming from Apache httpd. For more information on configuring the
<Connector>
element, see the Connector page in the official Tomcat documentation at http://tomcat.apache.org/tomcat-6.0-doc/config/http.html.

__________________

Today's tip was provided by sdozen12 on behalf of MuleSoft. Do you have a question on installing, configuring, or deploying Apache Tomcat? Submit it here.

Want to cash in on your IT savvy? Send your tip to tips@itworld.com. If we post it, we'll send you a $25 Amazon e-gift card.

Insider: How the basic tech behind the Internet works
Join the discussion
Be the first to comment on this article. Our Commenting Policies