Thursday, August 1, 2013

Multiple static directories with Nginx and Django

I had troubles setting up Nginx configuration to serve static files from two different Django applications. Finally, after searching hints for the solution from Nginx error logs, I managed to got the location configurations correctly.

The following solution may not be optimal, but at least it works. If you know how to achieve similar functionality more elegantly, give me a comment, thanks! :)

...
location /static/tools/ {
    alias /var/www/sites/mysite/tools/static/tools/;
}
location /static/editor/ {
    alias /var/www/sites/mysite/editor/static/editor/;
}
...