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?


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 http://isc.sans.org/diary.html?storyid=6601 .


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.

  • 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. – hdanniel 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;

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; }

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.