I am looking for a simple configuration to serve all files and directories inside a specific folder.
To be more precise, I try to serve everything in the pinax /static_media/ and /media/ /static_media/ , as it is with the same URL, and it is preferable to automatically index everything.
/static_media/
/media/
by the way, I ran python manage.py build_media --all , so all static content is under <project_name>/site_media/static
python manage.py build_media --all
<project_name>/site_media/static
Current configuration I'm 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 various setup instructions from different sites really confused me, for example
How to serve all existing static files directly using NGINX, but the proxy server remains on the 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 pretty simple, as I guessed. You need to set the root directory once and use the subdirectories 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 have a key to
Nginx does not stat