assets not being served in production with rails 4.1.0.rc1 nginx and unicorn -
i'm deploying rails 4.1.0.rc1 app production , appears working except no assets being served.
i deploying ubuntu 12.04 on nginx unicorn. webrick able serve assets with:
config.serve_static_assets = true
in production.rb.
interestingly, under nginx/unicorn, assets being referenced without fingerprint. i.e /assets/application.css instead of /assets/application-2c83bb5c879fd170625884df41e4b778.css
of course, when nginx goes serve asset, doesn't exist. issue unicorn/nginx setup, under webrick production (locally , on server) correct filename present , asset correctly served up.
other os specific parts, have been following https://www.digitalocean.com/community/articles/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5 .
config/unicorn.rb
# set working application directory # working_directory "/path/to/your/app" working_directory "/var/www/citysquares" # unicorn pid file location # pid "/path/to/pids/unicorn.pid" pid "/var/www/citysquares/pids/unicorn.pid" # path logs # stderr_path "/path/to/log/unicorn.log" # stdout_path "/path/to/log/unicorn.log" stderr_path "/var/www/citysquares/log/unicorn.log" stdout_path "/var/www/citysquares/log/unicorn.log" # unicorn socket listen "/tmp/unicorn.[app name].sock" listen "/tmp/unicorn.citysquares.sock" # number of processes # worker_processes 4 worker_processes 2 # time-out timeout 30
/etc/nginx/conf.d/default.conf
upstream app { # path unicorn sock file, defined server unix:/tmp/unicorn.citysquares.sock fail_timeout=0; } server { listen 80; server_name localhost; # application root, defined #root /root/citysquares/public; root /var/www/citysquares/public; try_files $uri/index.html $uri @app; location @app { proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_redirect off; proxy_pass http://app; } error_page 500 502 503 504 /500.html; client_max_body_size 4g; keepalive_timeout 10; }
any , appreciated, has me stumped!
try add "assets" block in config , restart nginx
server { # . . . location ^~ /assets/ { gzip_static on; expires max; add_header cache-control public; } # . . . }
Comments
Post a Comment