0

I'm getting a 404 not found error after deploying my rails app. I'm using: ubuntu, nginx, capistrano, & unicorn.

These are my configurations:

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

unicorn.rb

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

& on the server /etc/nginx/sites-available/default

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

Here the snippet from 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$

When I request /current/public/ instead of just /public/, I get forbidden 403. and the log is:

3 directory index of "/var/www/mysite/current/public/" is forbidden, client: *..*.*, server: mysite, request: "GET / HTTP/1.1"` – 
masegaloeh
  • 17,978
  • 9
  • 56
  • 104
dima
  • 101
  • 1
  • What's in your logs? – Michael Hampton May 08 '15 at 15:53
  • `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$` – dima May 08 '15 at 16:05
  • when i do /current/public/ instead of just /public/ i get **forbidden 403**. and the log is: ` *3 directory index of "/var/www/mysite/current/public/" is forbidden, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1"` – dima May 08 '15 at 16:10
  • Hi Dima, i am having a problem very similar to yours. Have you solved the problem? Can you give me some helps? Thanks! – Brian Jul 11 '15 at 07:36

0 Answers0