File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Reason(s) to Front Tomcat with Apache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Reason(s) to Front Tomcat with Apache" Watch "Reason(s) to Front Tomcat with Apache" New topic
Author

Reason(s) to Front Tomcat with Apache

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I'm wondering what the valid reasons are these days for fronting a web application running in Tomcat with Apache (httpd). Any truly static content we're delivering from AmazonS3. It just seems to me that Apache is just an extra process at this point when every bit of traffic is forwarded to Tomcat. Any insight is appreciated.


GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

A number of places I worked did this simply because Apache was deemed faster (rightly? Not sure.) than Tomcat at serving static resources. If the static resources come from somewhere else, that reasoning falls through.

Another place needed PHP support.

But most of the time I think that the reason is "We've always done it that way."


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The only other reason I can think of is that on our dev/staging servers we added basic auth in the apache config to lock down access to the application since they are public domains. This security is completely seperate from the web applications security. And I don't know how to do that in Tomcat.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

I think the place I'm doing some contract work for fronts with Apache for those types of security facilities. (But I tend to distrust the reasonings of the outfit that they're using for their IT as they've proven themselves to be the Marx Brothers on more than one occasion.)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

The only reason we've done it is to add load balancing to Tomcat.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Rob Spoor wrote:The only reason we've done it is to add load balancing to Tomcat.


Can you expand on that?
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

I've used Apache http server mainly to do load balancing, to handle ssl certificates and to implement rewrite rules. For some smaller web sites I'm using only Tomcat.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41054
    
  43
Ssl termination, load balancing and apache modules like php, rewrite and others (if you need those).


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Gregg Bolinger wrote:
Rob Spoor wrote:The only reason we've done it is to add load balancing to Tomcat.


Can you expand on that?

We have a clustered application (purchased) but it isn't load balanced. We put an Apache HTTPD server in front of it with mod_jk acting as load balancer. Our worker.properties file:
Any hit to the Apache server will end up at either of the two Tomcat instances, with session persistence enabled.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

Perhaps the most important reason to put Apache in front of Tomcat is that Apache can safely receive on port 80 and 443 without running as root. Tomcat cannot. So if you want to use the standard ports, proxy Tomcat or open up a major security vulnerability.

The idea that Apache can serve static content faster than Tomcat is one that needs to be taken out back and shot. Up until about Tomcat 4, yes, that was true, but reportedly since then improvements in Tomcat mean that there's little difference. If in doubt (and if it's important), measure, but this is mainly a bit of obsolete wisdom, that like all obsolete wisdom does more harm than good.

Other reasons for running Apache as a front for Tomcat:

* "One stop shopping" for multiple Tomcat servers running different apps
* load balancing for multiple Tomcat servers running the same apps
* Proxy access to Tomcat servers behind a firewall
* Normalization of URLs to hide the normal port and application context paths. General URL rewriting.
* More "One stop shopping". You can run a mix of J2EE and non-J2EE apps (cgi, PHP, Python and so forth) all from the same host.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reason(s) to Front Tomcat with Apache
 
Similar Threads
Apache tomcat and Jakarta tomcat
****ServletContext and WebApplication confusion****
Problem changing jsp property
Http port
HTTPS ..Apache.Tomcat or both?