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?


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.

  • 3
    Many use lighttpd or thttpd for the same reasons outlined above. – Joe Jun 14 '09 at 3:37
  • @joe: another one that's gaining popularity is NginX. it's freakingly fast, and the config file is geared specifically towards being used as a load balancing frontend for several servers. – Javier Jun 14 '09 at 13:18
  • Another question, then: If I were to do this with, say, a Java server behind Apache, would I use multiple instances? Thanks. – Sasha Chedygov Jun 15 '09 at 18:12
  • +1 for Nginx, it is used by some really busy sites. Very popular as a reverse proxy in Ukraine, Russia, China and US, according to Netcraft. news.netcraft.com/archives/web_server_survey.html – Taras Chuhay Jun 16 '09 at 17:22

As to your other question -

Another question, then: If I were to do this with, say, a Java server behind Apache, would I use multiple instances?

Depends :) Whats the load like? Whats the memory usage like? How would you distribute them - multiple Java app servers on the same box? Different boxes? The appropriate configuration depends on what the problem you're trying to solve is.

  • Well I'm just wondering if there would be any benefit to that. I understand that most Ruby web applications use a Mongrel cluster of about 9 Mongrel instances for various reasons; would that apply with Jetty (Java) as well? At this point I'm just using a web server and a database server, no application server, because I won't need it (not enough load). – Sasha Chedygov Jun 17 '09 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.