【发布时间】:2011-12-04 00:08:32
【问题描述】:
我正在寻找一种简单的配置来为特定文件夹中的所有文件和目录提供服务。
更准确地说,我正在尝试为 pinax /static_media/ 文件夹和 /media/ 文件夹中的所有内容提供相同的 url,并且最好自动索引所有内容。
顺便说一句,我运行了python manage.py build_media --all,所以所有静态内容都在<project_name>/site_media/static下
我正在使用的当前配置:
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/;
}
来自不同站点的所有不同配置说明真的让我很困惑,例如
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
环境信息:
- Xubuntu 10.04 在 VirtualBox 上运行
- nginx 1.1.4
- pinax 0.72
- django 1.0.4
- 通过 nginx 运行 django 的 fastcgi
【问题讨论】:
标签: django nginx pinax static-files