python – Nginx在静态文件上抛出403禁止

前端之家收集整理的这篇文章主要介绍了python – Nginx在静态文件上抛出403禁止前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个django应用程序,python 2.7与gunicorn和Nginx.

Nginx抛出403 Forbidden错误,如果我尝试查看我的静态文件夹中的任何东西@:

/home/ubuntu/virtualenv/myapp/myapp/homelaunch/static

Nginx配置(/ etc / Nginx / sites-enabled / myapp)包含:

server {
        listen       80;
        server_name     *.myapp.com;
        access_log /home/ubuntu/virtualenv/myapp/error/access.log;
        error_log /home/ubuntu/virtualenv/myapp/error/error.log warn;
        connection_pool_size 2048;

        fastcgi_buffer_size 4K;
        fastcgi_buffers 64 4k;

        root /home/ubuntu/virtualenv/myapp/myapp/homelaunch/;

        location /static/ {
            alias /home/ubuntu/virtualenv/myapp/myapp/homelaunch/static/;
        }

        location / {
            proxy_pass http://127.0.0.1:8001;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
        }
    }

error.log包含:

2013/11/24 23:00:16 [error] 18243#0: *277 open() "/home/ubuntu/virtualenv/myapp/myapp/homelaunch/static/img/templated/home/img.png" Failed (13: Permission denied),client: xx.xx.xxx.xxx,server: *.myapp.com,request: "GET /static/img/templated/home/img2.png HTTP/1.1",host: "myapp.com",referrer: "http://myapp.com/"

access.log包含

xx.xx.xx.xxx - - [24/Nov/2013:23:02:02 +0000] "GET /static/img/templated/base/animg.png HTTP/1.1" 403 141 "http://myapp.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:25.0) Gecko/20100101 Firefox/25.0"
xx.xx.xx.xxx - - [24/Nov/2013:23:02:07 +0000] "-" 400 0 "-" "-"

我尝试只是在/ static /中查看一个.css文件,并在源代码中抛出一个这样的错误

403 Forbidden403 ForbiddenNginx/1.1.19
@H_301_43@
最佳答案@H_301_43@
看起来用户Nginx正在运行(Nginx?)缺少读取本地文件/home/ubuntu/virtualenv/myapp/myapp/homelaunch/static/img/templated/home/img.png的权限.您可能想要检查文件权限以及层次结构中目录的权限.@H_301_43@

猜你在找的Nginx相关文章