I'm about to deploy a Django application on a nginx web server, and want to make sure I'm building the system correctly.
It seems to be common wisdom that if you are deploying Django on an apache server, then you should still put an nginx server in front of the application to serve static files, at which nginx is more performant.
If instead of apache for the Django code, I would like to use nginx + FastCGI to host the Django application, is there any reason to configure a second nginx install to sit in front of the nginx server that is serving dynamic content, to handle static content as well as redirection to the dynamic content?
Specifically, will there be different configuration parameters for the static and dynamic content that would make me want to keep the servers separate, or can I host it all in a single nginx installation, with some of the URLs being mapped to django content, and the rest being mapped to static content served from the same nginx install?
Thanks for your advice!
Most config directives can live inside location blocks (i.e., they are not global-only) and it's very common to do this is practice. You should have no trouble setting this up using only 1 instance of nginx.
One of the great things about this is that you can set it up this way initially and then change your mind later by switching the location block to pass through to a backend server without any of that being visible to the outside world.
So go ahead and do it on one server now, knowing that you can put in a backend server or cluster later as you need to scale up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With