nginx在生产模式下加载错误的资产文件路径

时间:2015-07-22 14:23:34

标签: ruby-on-rails nginx sass asset-pipeline sprockets

nginx试图给我这样的资产文件。

  

获取http://www.lazyair.co/assets/kode/css/font-awesome.min.css

但那些文件不存在。实际的文件路径应该是丑陋的。

  

获取http://www.lazyair.co/assets/kode/css/font-awesome2131e1321e12qd.min.css

Demo website

nginx.conf上的错误根本原因

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

nginx.conf

  root /home/sample/rails-app/public ;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @rails-app;

  location @rails-app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://rails-app;
    # Reverse proxy cache
    proxy_cache default;
    proxy_cache_lock on;
    proxy_cache_use_stale updating;
    add_header X-Cache-Status $upstream_cache_status;
  }

production.rb

  config.serve_static_files = false

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  #config.assets.js_compressor = :yui
  config.assets.css_compressor = :sass   
  config.assets.digest = true

application.html.haml

%link{:href => asset_path("kode/css/root.css"), :rel => 

root.css.scss

@import 'font-awesome.min.css';

/* ================================================
Main Css
================================================ */
/* Bootstrap Main Css File (unedited) */
@import 'bootstrap.css';

/* Theme Style */
@import 'style.css';

/* Responsive Style */
@import 'responsive.css';

/* Shortcuts Css Codes */
@import 'shortcuts.css';

/* ================================================
Plugin Css
================================================ */
/* Awesome Bootstrap Checkbox */
@import 'plugin/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css';

/* Bootstrap Select */
@import 'plugin/bootstrap-select/bootstrap-select.css';

/* Bootstrap Select */
@import 'plugin/bootstrap-toggle/bootstrap-toggle.min.css';

/* Bootstrap wysihtml5 */
@import 'plugin/bootstrap-wysihtml5/bootstrap-wysihtml5.css';

/* Summernote */
@import 'plugin/summernote/summernote.css';
@import 'plugin/summernote/summernote-bs3.css';

/* Sweet Alert */
@import 'plugin/sweet-alert/sweet-alert.css';

/* Data Tables */
@import 'plugin/datatables/datatables.css';

/* Chartist */
@import 'plugin/chartist/chartist.min.css';

/* Rickshaw */
@import 'plugin/rickshaw/rickshaw.css';
@import 'plugin/rickshaw/detail.css';
@import 'plugin/rickshaw/graph.css';
@import 'plugin/rickshaw/legend.css';

/* Date Range Picker */
@import 'plugin/date-range-picker/daterangepicker-bs3.css';

/* Full Calendar */
@import 'plugin/fullcalendar/fullcalendar.css';

0 个答案:

没有答案