Web-server – Why use Apache in front of another web server

apache-2.2web-server

I've seen a lot of web server setups where Apache is in front of another web server. The most prominent examples of these are the Java web servers, e.g. Glassfish, Tomcat, etc. What is the point of this? I realize the point of putting Apache in front of, say, a Mongrel cluster is load balancing, but what about other servers? What are the reasons for doing this?

Best Answer

Web application servers are good at hosting their application (Ruby, Java, etc), but not as good as Apache at hosting static files, or providing load balancing/failover (mod_proxy), security/filtering (mod_security), rewriting (mod_rewrite) etc. Therefore it's quite common to use Apache as the front end, possibly serving all the static content, and then proxying requests to the application server (mongrel, tomcat, etc).

Apache is a well-audited piece of code that has "been around the block" somewhat more than the newer servers, so it makes sense to have it as the server that faces the untrusted Internet. It also means you can put your application servers inside your network, and your Apache servers in your DMZ.