2012-03-29 148 views
1

我正在使用Nginx + Unicorn和我的rails 3.0.3应用程序。请求图像返回403/404

这里是我的应用程序nginx的配置:

upstream unicorn { 
    server unix:/tmp/unicorn.myapp.sock fail_timeout=0; 
} 

server { 
    listen 80 default deferred; 
    root /home/deployer/apps/myapp/current/public; 

    try_files $uri/index.html $uri @unicorn; 
    location @unicorn { 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://unicorn; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

下面是应用程序的public/images目录列表:

lrwxrwxrwx 1 deployer admin  56 2012-03-28 17:06 other -> /home/deployer/other_images/ 
-rw-rw-r-- 1 deployer admin 6646 2012-03-28 17:08 rails.png 

正如你可以看到other是一个符号链接。下面是/home/deployer/other_images/

-rw-r--r-- 1 deployer admin 2271 2012-02-03 17:24 1.jpg 

目录列表在浏览器中,我可以拉起来http://<domain>/images/rails.pnghttp://<domain>/images/other/1.jpg还是返回了public/404.html页面(“你要找的页面不存在”)。

我在做什么错?这是一个权限问题的文件/目录之一?我的nginx配置没有正确设置?

UPDATE

当我以下内容添加到应用程序的nginx的配置(以下root),并请求1.jpg,我拿回403权限被拒绝:

location ^~ /images/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
} 

回答

0

我固定它。 /home/deployer/other_images目录没有读取权限。