Rails Nginx - 404 Not Found - / public文件夹内容出错

时间:2014-06-29 20:46:57

标签: ruby-on-rails nginx

在Heroku待了一段时间之后,我将转向DigitalOcean来托管我的博客。但是我收到了文件夹/public/fonts的过滤器的麻烦。

我认为这是因为Nginx配置问题。我附上了conf文件belog。

我是这个东西的新手。我想知道为每个404目录复制/ assets seciton。但这对我来说并不合理。

如果有人能够指出错误并给出建议,我会很高兴。

upstream guruof.it {
  server unix:///var/run/guruofit.sock;
}

server {
  listen 80;
  server_name guruof.it; # change to match your URL
  root /var/www/guruof.it/public; # I assume your app is located at that location

  location / {
    proxy_pass http://guruof.it; # match the name of upstream directive which is defined above
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location @guruof.it {
    proxy_redirect off;
    proxy_pass http://guruof.it;
  }

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

1 个答案:

答案 0 :(得分:0)

如果您使用capistrano进行部署,则需要将“当前”添加到根路径

类似这样的事情

root /var/www/guruof.it/current/public;

这应该有效。