我想让nginx
为缓存任务提供静态文件。
但我从nginx错误日志中得到No such file or directory
。
似乎无法提供root-c452663d516929cd4bb4c1cd521971eb.css
中包含的css文件。
我该如何修复错误
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
#config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.serve_static_files = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
/* Summernote */
@import url('plugin/summernote/summernote.css');
@import url('plugin/summernote/summernote-bs3.css');
/* Sweet Alert */
@import url('plugin/sweet-alert/sweet-alert.css');
/* Data Tables */
@import url('plugin/datatables/datatables.css');
/* Chartist */
@import url('plugin/chartist/chartist.min.css');
/* Rickshaw */
@import url('plugin/rickshaw/rickshaw.css');
@import url('plugin/rickshaw/detail.css');
@import url('plugin/rickshaw/graph.css');
@import url('plugin/rickshaw/legend.css');
location / {
try_files $uri @sample;
gzip_static on;
expires max;
add_header Cache-Control public;
}
location @sample {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://sample;
}
location ~* ^/assets/ {
# Per RFC2616 - 1 year maximum expiry
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
2015/07/22 17:27:02 [error] 9891#0: *9 open() "/var/public/assets/kode/css/plugin/date-range-picker/daterangepicker-bs3.css" failed (2: No such file or directory), client: 118.166.217.131, server: www.localhost, request: "GET /assets/kode/css/plugin/date-range-picker/daterangepicker-bs3.css HTTP/1.1", host: "localhost", referrer: "http://localhost/assets/kode/css/root-c452663d516929cd4bb4c1cd521971eb.css"
2015/07/22 17:27:02 [error] 9891#0: *10 open() "/var/public/assets/kode/css/plugin/rickshaw/legend.css" failed (2: No such file or directory), client: 118.166.217.131, server: www.localhost, request: "GET /assets/kode/css/plugin/rickshaw/legend.css HTTP/1.1", host: "localhost", referrer: "http://localhost/assets/kode/css/root-c452663d516929cd4bb4c1cd521971eb.css"
2015/07/22 17:27:02 [error] 9891#0: *11 open() "/var/public/assets/kode/css/plugin/rickshaw/detail.css" failed (2: No such file or directory), client: 118.166.217.131, server: www.localhost, request: "GET /assets/kode/css/plugin/rickshaw/detail.css HTTP/1.1", host: "localhost", referrer: "http://localhost/assets/kode/css/root-c452663d516929cd4bb4c1cd521971eb.css"
2015/07/22 17:27:02 [error] 9891#0: *5 open() "/var/public/assets/kode/css/plugin/fullcalendar/fullcalendar.css" failed (2: No such file or directory), client: 118.166.217.131, server: www.localhost, request: "GET /assets/kode/css/plugin/fullcalendar/fullcalendar.css HTTP/1.1", host: "localhost", referrer: "http://localhost/assets/kode/css/root-c452663d516929cd4bb4c1cd521971eb.css"
app_path = File.expand_path('../', File.dirname(__FILE__))
pidfile "#{app_path}/tmp/pids/puma.pid"
bind "unix:///tmp/puma.lazyair.sock"
stdout_redirect "#{app_path}/log/puma.stdout.log", "#{app_path}/log/puma.stderr.log", true
workers Integer(ENV['WEB_CONCURRENCY'] || 6)
threads_count = Integer(6)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3457
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
on_worker_boot do
ActiveRecord::Base.establish_connection
end
activate_control_app