This blog is now hosted at consciou.us

Thursday, February 25, 2010

Nginx for static content

At Sage Steps, we're using Nginx (http://wiki.nginx.org/) as a front-end web server.  It serves up our static content, and load balances the back-end Apache servers.


location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|html|htm)$ {
root /static;
}

All of the dynamic stuff is happening in Django running under Apache using ModWsgi. Since this is a fairly heavy stack (Apache is very robust and featureful, but is also somewhat romanesque).

So that we're not using a 10 lb sledgehammer to do finish nails (remind me to tell you about the time that I saw a full-bird Colonel drop a sledgehammer on a Lt. Colonel's foot!), we basically tell Nginx to serve up anything ending in "jpg", "xls", "pdf", etc. from the static directory, without talking to Apache.

No comments: