【问题标题】:Nginx + Rails 4 assets not foundNginx + Rails 4 资产未找到
【发布时间】:2014-10-10 01:00:04
【问题描述】:

我刚刚将我的第一个 Rails 应用程序部署到生产环境,但遇到错误:我的资产由于某种原因没有由 nginx 提供服务。资产已编译并存在。名称正确,路径正确。而不是资产 nginx 向我发送 404 错误。作为服务器,如果这很重要,我会使用 Puma。

我对该部分的配置如下所示:

  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;
  }

【问题讨论】:

    标签: ruby-on-rails nginx http-status-code-404 assets


    【解决方案1】:

    我找到了问题的根源。我使用 Capistrano 进行部署,所以在我的 nginx 配置中我给出了错误的根路径

    server {
      listen 80;
      server_name mydomain.com www.mydomain.com;
      root /var/www/my_portal/current/public;
    

    我错过了根路径中的current 部分,导致 Capistrano 将其符号链接到我的应用程序的当前版本。

    【讨论】:

    • 谢谢!!!我已经仔细检查了这个root 配置,但不知何故忽略了current 部分......
    猜你喜欢
    • 1970-01-01
    • 2015-12-16
    • 1970-01-01
    • 1970-01-01
    • 2019-01-18
    • 2014-04-21
    • 1970-01-01
    • 1970-01-01
    • 2013-09-13
    相关资源
    最近更新 更多