Ruby on rails 使用rails 4.1.0.rc1 nginx和unicorn在生产中未提供服务的资产
我正在将rails 4.1.0.rc1应用程序部署到生产环境中,除了没有提供任何资产外,其他一切都正常工作 我正在使用Unicorn在Nginx上部署Ubuntu12.04。Webrick能够为资产提供以下服务:Ruby on rails 使用rails 4.1.0.rc1 nginx和unicorn在生产中未提供服务的资产,ruby-on-rails,nginx,unicorn,ruby-on-rails-4.1,Ruby On Rails,Nginx,Unicorn,Ruby On Rails 4.1,我正在将rails 4.1.0.rc1应用程序部署到生产环境中,除了没有提供任何资产外,其他一切都正常工作 我正在使用Unicorn在Nginx上部署Ubuntu12.04。Webrick能够为资产提供以下服务: config.serve_static_assets = true 在production.rb中 有趣的是,在nginx/unicorn下,资产被引用时没有指纹。即 /assets/application.css 而不是 /资产/应用程序-2C83BB5C879FD17062588
config.serve_static_assets = true
在production.rb中
有趣的是,在nginx/unicorn下,资产被引用时没有指纹。即
/assets/application.css
而不是
/资产/应用程序-2C83BB5C879FD1706258844DF41E4B778.css
当然,当nginx为资产服务时,它并不存在。这只是unicorn/nginx设置的一个问题,在webrick作为生产(本地和服务器上)的情况下,存在正确的文件名,并且正确地提供了资产
除了操作系统特定的部分之外,我一直在关注
config/unicorn.rb
# Set the 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 to 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 to Unicorn SOCK file, as defined previously
server unix:/tmp/unicorn.citysquares.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
# Application root, as defined previously
#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;
}
感谢所有的帮助,这让我很难堪 尝试在配置中添加“资产”块,然后重新启动nginx
server {
# . . .
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
# . . .
}
您是否预编译了资产?谢谢您的回复,是的,我预编译了。我可以看到编译后的资产,webrick可以为它们提供服务。我在“error_page”的正上方添加了该块,然后重新启动,但仍然不走运。资产仍显示在没有指纹的页面源中。