Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've read a lot about this issue (including all threads in this site) and couldn't come to a conclusive decision.

What is considered better (performance and security wise) for very high load sites (millions of users per day):

  1. standalone Nginx + PHP + SQL
  2. Nginx as a revers proxy for Apache + PHP + SQL

What I don't get is - if Nginx can run dynamic content why use Apache at all?

share|improve this question
up vote 3 down vote accepted

I have 20+ web servers running nginx+php-fpm behind a pair of HAProxy balancers. In my opinion, and from my own experience, the is the optimal setup. Not taking anything away from Apache (I use it for over 10 years), but Nginx simply blows its socks off.

HAProxy is the best open source load balancer. Period. I have tried many, including commercial offerings. I installed nginx on the load balancer as well to offload the SSL. It works like a charm, even under high load.

Splitting all the static content (images, css, js, etc) to separate nginx(s) gives you a further performance boost. HAProxy can send all static requests to a separate server, meaning you have the benefit of parallel requests in your back end systems.

If you do try HAProxy, remember to keep the MAXCONN setting for the web servers to a low (like 20 of 40) value. I see so many posts that have the web server maxconn setting being set to something like 1000 - which will result in HAProxy overloading a node in no time flat.

share|improve this answer
wow great answer!! i think i got what i needed :) – Danny Valariola Oct 30 '12 at 19:27
No sweat. Glad it helped. – gmck Oct 31 '12 at 18:09

Unless you want to use Apache-specific features there is no point in using it behind Nginx.

share|improve this answer
Thx, can you think of any Apache specific features i might be missing / need for my app? – Danny Valariola Oct 30 '12 at 17:58
There are over 500 Apache modules that provide loads of different functions and vast majority of the less popular ones don't have Nginx equivalent. See complete list here: – c2h5oh Oct 31 '12 at 15:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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