儘管在/public
目錄,如果我訪問http://site.example.com/favicon.ico
我得到404頁面。有趣的是,如果我嘗試訪問http://site.example.com/500.html
,我也會收到404頁面,導致我認爲/public
文件沒有被提供。我正在用Unicorn運行Nginx。 Rails中是否有任何設置會禁用/public
資產?Rails 3.1 favicon.ico沒有服務
編輯 我的nginx的配置:
server {
listen 80;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
# Location of our static files
location ~ ^/(assets)/ {
root /srv/ctr/current/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
location/{
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
# error_page 500 502 503 504 /500.html;
# location = /500.html {
# root /var/rails/testapp/public;
# }
}
我有我的路線root :to => 'reports#index'
,但我不明白怎麼會有所作爲。
解決方案 我感動行root /srv/ctr/current/public;
以上keepalive_timeout 5;
我無法證實的Rails 3.1,Nginx的和獨角獸無視我的圖標,404.html或500。 HTML(從我的公共目錄)。這是我的配置,檢查是否有任何區別:https://gist.github.com/1589113祝你好運:) – 2012-01-10 13:38:08