Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm testing nginx with different configurations to replace an architecture working with squid + apache. I know that I can use nginx to manage static requests and load balancing but I'm interested in one particular solution that I don't understand clearly:

I'm using 2 nginx servers (balanced) with the proxy_pass setting to pass all requests to an apache server. When one client makes a request to the site one of the nginx servers process it and send it to the apache server. Now, how this behaviour could be an improvement to my system?, it seems that all requests are passing through apache and I don't see benefit at all. What happens when 100 simultaneous connections pass through nginx? The 100 connections will be going to the apache server or is some kind of internal behaviour that allows an small impact into apache?

share|improve this question
up vote 1 down vote accepted

Nginx can help your Apache when you have a lot of slow connections to your sites. For example nginx state-machine architecture isn't vulnerable to Slowloris DDoS .

share|improve this answer
Apache 2.2.15 released with which allows you to hook the request process early enough to prevent slowloris from affecting the server. – user6738237482 Jun 8 '10 at 22:18

I know that nginx can perform a lot of functions, but why not delegate each piece of the architecture to software that does one piece of it really well? Consider some, or all, of these pieces: pound or haproxy for the load balancing, varnish or squid for the reverse caching proxy, and having nginx and apache on the back end for static and dynamic content (respectively).

That said, I'm not exactly sure what your question is. You've told nginx to pass all requests (I assume by "pass" you mean not caching them) to an apache back-end. Without caching, the benefit would be distributing the load across multiple apache servers on the back end. If you only have one back-end apache server, then you'll only get the benefit by caching the content, not just passing requests straight through.

More details about your setup, and what you want to do, would help.

share|improve this answer
Thanks, I see a number of nginx configurations that simply proxypass request from nginx to apache. I thought that nginx was working as some kind of accelerator for apache. – HD. Jul 14 '09 at 22:12
Well, it works as an accelerator in the sense that nginx handles all the static requests leaving the Apache instance free to handle the "heavy" transactions. – Jauder Ho Jul 15 '09 at 11:26

Agreed - let nginx serve static content directly, and Apache only has to handle the PHP stuff - that means many fewer Apache workers which ultimately means a much better performance.

  location / {
    proxy_pass http://backendwww;
  location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|swf|flv|mp3|m4v)$ {
    access_log off;
    expires    30d;
    root /var/www/application_webroot;
    error_page 404 = @fallback;
  location @fallback {
    proxy_pass http://backendwww;
  location ~ /\.ht {
    deny  all;
share|improve this answer

Agree with Zero*, let enginx handle all static, however, a simpler configuration is just to pass php to the backend, rather than specifying what not to pass to Apache/PHP eg:

location ~ .(php|phtml?)$ { proxy_pass http://backendwww; }

share|improve this answer

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.