簡體   English   中英

Rails 4資產:預編譯不工作Nginx + Thin配置

[英]Rails 4 assets:precompile not working Nginx + Thin configuration

請幫我。 我在vps上有rails4 app runnig。

我在nginx配置中很瘦

upstream myapp {
  server 127.0.0.1:3000;
  server 127.0.0.1:3001;
  server 127.0.0.1:3002;
}
server {
  listen   80;
  server_name .example.com;

  access_log /var/www/myapp.example.com/log/access.log;
  error_log  /var/www/myapp.example.com/log/error.log;
  root     /var/www/myapp.example.com;
  index    index.html;

  location / {
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;
    proxy_redirect  off;
  try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;
 }

  location @ruby {
   proxy_pass http://myapp;
  }
}

這是我的生產環境設置

# Disable Rails's static asset server (Apache or nginx will already do this).
 config.serve_static_assets = true

 # 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
 config.assets.precompile = ['*.js', '*.css', '*.css.erb']

在公共/資產/我可以看到編譯js css和圖像smyd像manydigits.png但當我去我的網站有資產404

  location ~ ^/(assets)/{
     root /var/www/myapp.example.com/public;
     expires max;
     add_header Cache-Control public;
  }

nginx config中的這段代碼修復了我的資產問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM