Note that there are some explanatory texts on larger screens.

plurals
  1. POrails deployment using nginx & unicorn: 403 forbidden error
    primarykey
    data
    text
    <p>I have just setup a VPS (Centos 6.3) and deploy my app using capistrano. The VPS runs nginx &amp; unicorn. I'm getting a 403 Forbidden error when visiting the server: this line appears in /var/log/nginx/error.log:</p> <pre><code>*5 directory index of "/var/www/current/public/" is forbidden, client: xxxxx, server: xxx, request: "GET / HTTP/1.1", host: "xxxx" </code></pre> <p><strong>However, if I add the index.html to my rails app in ./public, everything works without problem. This makes me think that the routes aren't working.</strong></p> <p>I have also set the permissions for all folders of /var/www using chmod -R 755 * (probably not the best idea in the long run but wanted to exclude this as a source of error). Is there any other way to debug this in more detail (the error.log file does not tell me anything else)?</p> <p>Any help is much appreciated.</p> <p>This is my routes.rb file (everything's working locally in development)</p> <pre><code>MyTest::Application.routes.draw do root :to =&gt; 'welcome#index' end </code></pre> <p>The following is my nginx.conf file:</p> <pre><code>upstream unicorn { server unix:/tmp/unicorn.blog.sock fail_timeout=0; } server { listen 80 default deferred; # server_name example.com; root /var/www/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; client_max_body_size 4G; keepalive_timeout 5; } </code></pre> <p>This is the unicorn_init.sh:</p> <pre><code>#!/bin/sh set -e # Feel free to change any of the following variables for your app: TIMEOUT=${TIMEOUT-60} APP_ROOT=/var/www/current PID=$APP_ROOT/tmp/pids/unicorn.pid CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production" AS_USER=########## set -u OLD_PIN="$PID.oldbin" sig () { test -s "$PID" &amp;&amp; kill -$1 `cat $PID` } oldsig () { test -s $OLD_PIN &amp;&amp; kill -$1 `cat $OLD_PIN` } run () { if [ "$(id -un)" = "$AS_USER" ]; then eval $1 else su -c "$1" - $AS_USER fi } case "$1" in start) sig 0 &amp;&amp; echo &gt;&amp;2 "Already running" &amp;&amp; exit 0 run "$CMD" ;; stop) sig QUIT &amp;&amp; exit 0 echo &gt;&amp;2 "Not running" ;; force-stop) sig TERM &amp;&amp; exit 0 echo &gt;&amp;2 "Not running" ;; restart|reload) sig HUP &amp;&amp; echo reloaded OK &amp;&amp; exit 0 echo &gt;&amp;2 "Couldn't reload, starting '$CMD' instead" run "$CMD" ;; upgrade) if sig USR2 &amp;&amp; sleep 2 &amp;&amp; sig 0 &amp;&amp; oldsig QUIT then n=$TIMEOUT while test -s $OLD_PIN &amp;&amp; test $n -ge 0 do printf '.' &amp;&amp; sleep 1 &amp;&amp; n=$(( $n - 1 )) done echo if test $n -lt 0 &amp;&amp; test -s $OLD_PIN then echo &gt;&amp;2 "$OLD_PIN still exists after $TIMEOUT seconds" exit 1 fi exit 0 fi echo &gt;&amp;2 "Couldn't upgrade, starting '$CMD' instead" run "$CMD" ;; reopen-logs) sig USR1 ;; *) echo &gt;&amp;2 "Usage: $0 &lt;start|stop|restart|upgrade|force-stop|reopen-logs&gt;" exit 1 ;; esac </code></pre> <p>And finally, my Gemfile:</p> <pre><code>source 'https://rubygems.org' gem 'rails', '3.2.12' # Bundle edge Rails instead: # gem 'rails', :git =&gt; 'git://github.com/rails/rails.git' gem 'pg' gem 'execjs', '~&gt; 1.4.0' gem 'therubyracer' gem "less-rails" # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~&gt; 3.2.3' gem 'coffee-rails', '~&gt; 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms =&gt; :ruby gem 'uglifier', '&gt;= 1.0.3' end gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~&gt; 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server gem 'unicorn' # Deploy with Capistrano gem 'capistrano' # To use debugger # gem 'debugger' gem "haml", "~&gt; 4.0.0" gem 'twitter-bootstrap-rails', '~&gt; 2.2.6' gem "simple_form", "~&gt; 2.1.0" </code></pre> <p>This is my unicorn.rb:</p> <pre><code>root = "/var/www/current" working_directory root pid "#{root}/tmp/pids/unicorn.pid" stderr_path "#{root}/log/unicorn.log" stdout_path "#{root}/log/unicorn.log" listen "/tmp/unicorn.blog.sock" worker_processes 4 timeout 30 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload