I am looking for a simple configuration to serve all files and directories inside a particular folder.
To be more precise I am trying to serve everything inside the pinax /static_media/
folder and /media/
folder as it is with the same url, and preferably auto index everything .
by the way I have run python manage.py build_media --all
so all static content is under <project_name>/site_media/static
The current configuration I am using :
server {
listen 80;
server_name QuadraPaper;
access_log /home/gdev/Projects/QuardaPaper/access_log.log;
location ^*/site_media/*$
{
autoindex on;
access_log off;
root /home/gdev/Projects/QuardaPaper/site_media;
}
location /media/ {
autoindex on;
root /home/gdev/Projects/QuardaPaper/media/;
}
All the different configuration instructions from various sites has really confused me , for example
How to serve all existing static files directly with NGINX, but proxy the rest to a backend server.
http://coffeecode.net/archives/200-Using-nginx-to-serve-static-content-with-Evergreen.html
https://serverfault.com/q/46315/91723
http://wiki.nginx.org/Pitfalls
http://pinaxproject.com/docs/0.7/media/#ref-media-devel
Environment information:
I found the answer , It was Quite simple as i guessed . One has to set the root directory once and use the sub-directories as the location
server {
listen 80;
server_name QuadraPaper;
access_log /home/gdev/Projects/QuardaPaper/access_log.log;
root /home/gdev/Projects/QuardaPaper;
location /site_media/ {
autoindex on;
access_log off;
}
location /media/ {
autoindex on;
}
}
I got a clue from