禁止[文件夹]的Nginx fastcgi django目录索引

时间:2014-10-08 12:19:14

标签: django nginx fastcgi

我正在尝试使用Nginx通过fastcgi反向代理django。 我遇到了一个非常奇怪的问题:

访问http:// {localhost}:8888 / admin /是正确的。 但http:// {localhost}:8888 / staticexample /是403禁止的。 (我用Google搜索了一些,并运行命令chmod -R 775 staticexample)。

(staticexample只是一个视图使用temple和静态资源)

配置如下所示,请提供帮助或建议。

django.conf>>>>

upstream django {
    server 127.0.0.1:8000 fail_timeout=0;
}

server {
    listen 8888;
    server_name 127.0.0.1;
    charset utf-8;

location / {
    fastcgi_pass django;
    #include fastcgi_params; # double admin
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_pass_header Authorization;
    fastcgi_intercept_errors off;
    }
}

nginx.conf>>>>

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    include django.conf;
}

谢谢&的问候,

Project的urls.py>>>>>

 urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'learning.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^staticexample/', include('staticexample.urls')),
)

Staticexample app的urls.py>>>>

urlpatterns = patterns('',
    url(r'^upload$', views.upload, name='upload'),
    url(r'^$', views.index, name='index'),
)

添加了项目和应用的urls.py。

0 个答案:

没有答案