I'm setting up a Django server with Apache + mod___wsgi and nginx as a static media server.

Which server should I put in front of the other? Apache using mod___proxy or nginx? I've heard different people say different things.

From what I understand, putting nginx in front is slightly faster, but I lose the ability to use .htaccess files and mod_rewrites. It's also slightly more complex to set up.

Is this correct? Lets discuss :-)


I've heard that the proxying taking place in either apache or nginx is so cheap, it really doesn't matter which server does it. That apache doesn't "waste" any resources until proxying is done. I'm really trying to get my head around this stuff, I'm really a coder :P

  • HD: Did you provide a link to proxy_pass? Is it a configuration option in nginx or apache? – jamting Sep 27 '09 at 21:00
  • It's a nginx directive. I edited my answer with the link. – hdanniel Sep 29 '09 at 13:49

You can put nginx in front of Apache and [proxy_pass][1] all the non-static requests with the ability to use apache's mod_rewrite. It works and is very easy to setup.

Another option is to put both servers at the same level using a different domain or subdomain for static files pointing to the nginx server.

Apache in front of nginx ... I will not use it. What we need in these setups is reduce the load and memory use of the Apache server, so nginx in front or at the same level are the best choices.


proxy_pass directive in nginx: http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass

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.