部署后 ruby​​ on rails 404 未找到

部署后 ruby​​ on rails 404 未找到

部署 rails 应用后,我收到 404 未找到错误。我使用的是:ubuntu、nginx、capistrano 和 unicorn。

这些是我的配置:

nginx.conf

upstream unicorn {
  server unix:/tmp/unicorn.mysite.sock fail_timeout=0;
}

server {
  server_name dima;
  return 301 $scheme://mysite$request_uri;
}

server {
  listen 80 default deferred;
  server_name dima;  
  root /var/www/mysite/current/public; 

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

  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
  keepalive_timeout 10;
}

独角兽

root = "/var/www/mysite"
working_directory root

pid "#{root}/tmp/pids/unicorn.pid"

stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"

worker_processes Integer(ENV['WEB_CONCURRENCY'])
timeout 30
preload_app true

listen '/tmp/unicorn.spui.sock', backlog: 64

unicorn_init.sh

TIMEOUT=${TIMEOUT-60}
APP_ROOT=/var/www/mysite
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="cd $APP_ROOT; ~/.rbenv/bin/rbenv exec bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
AS_USER=dima
set -u

& 在服务器上/etc/nginx/站点可用/默认

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        server_name mysite;
        #passenger_enabled on;
        #rails_env production;
        root /var/www/mysite/public;

        error_page 500 502 503 504  /50x.html;
        location = /50.x.html {
            root html;
        }
}   

以下是error.log

2015/05/08 15:33:12 [error] 3383#0: *28 "/var/www/mysite/public/index.html" is not found (2: No such file or directory), client:*.*.*.*, server: mysite, request: "GET / HTTP/1.1$

当我请求/current/public/而不是仅仅请求时/public/,我被禁止 403。日志是:

3 directory index of "/var/www/mysite/current/public/" is forbidden, client: *..*.*, server: mysite, request: "GET / HTTP/1.1"` – 

相关内容