我正在按照此说明http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/使用 puma 和 nginx 设置 rails(4.0.0) 应用程序。但是所有背景图片和一些js都不起作用。
my_app.conf
upstream my_app {
server unix:///var/run/my_app.sock;
}
server {
listen 80;
server_name my_app_url.com; # change to match your URL
root /var/www/my_app/public; # I assume your app is located at that location
location / {
proxy_pass http://my_app; # match the name of upstream directive which is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
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;
}
}
生产.rb
config.eager_load = true
config.assets.precompile += Ckeditor.assets
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
config.log_level = :info
# config.log_tags = [ :subdomain, :uuid ]
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# config.cache_store = :mem_cache_store
# config.action_controller.asset_host = "http://assets.example.com"
# config.assets.precompile += %w( search.js )
# config.action_mailer.raise_delivery_errors = false
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
# config.autoflush_log = false
config.log_formatter = ::Logger::Formatter.new