【发布时间】:2012-03-29 14:27:46
【问题描述】:
我正在使用 Nginx + Unicorn 和我的 rails 3.0.3 应用程序。
这是我的应用程序的 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.png,但http://<domain>/images/other/1.jpg 正在返回public/404.html 页面(“您要查找的页面不存在”)。
我做错了什么?文件/目录之一是否存在权限问题?我的 nginx 配置是否设置不正确?
更新
当我将以下内容添加到应用程序的 nginx 配置(root 下方)并请求 1.jpg 时,我得到了 403 Permission denied:
location ^~ /images/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
【问题讨论】:
标签: ruby-on-rails nginx unicorn