title: nginx and unicorn not working
body: <p>I set nginx and unicorn on ubuntu14.04 to access my rails app!</p>
  <p>but, I access my domain, chrome responsed 'connection refused'</p>
  <p>I don't know why...</p>
  <p>How can I resolve this problem?</p>
  <p>There is my nginx.conf and unicorn file.</p>
  <p>【nginx.conf】</p>
  <pre><code>events {
      worker_connections 768;
      # multi_accept on;
  }
  
  http {
  
      ##
      # Basic Settings
      ##
  
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 65;
      types_hash_max_size 2048;
      # server_tokens off;
  
      # server_names_hash_bucket_size 64;
      # server_name_in_redirect off;
  
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
  
      ##
      # Logging Settings
      ##
  
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;
  
      ##
      # Gzip Settings
      ##
  
      gzip on;
      gzip_disable &quot;msie6&quot;;
  
      # gzip_vary on;
      # gzip_proxied any;
      # gzip_comp_level 6;
      # gzip_buffers 16 8k;
      # gzip_http_version 1.1;
      # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  
      ##
      # nginx-naxsi config
      ##
      # Uncomment it if you installed nginx-naxsi
      ##
  
      #include /etc/nginx/naxsi_core.rules;
  
      ##
      # nginx-passenger config
      ##
      # Uncomment it if you installed nginx-passenger
      ##
      
      #passenger_root /usr;
      #passenger_ruby /usr/bin/ruby;
  
      ##
      # Virtual Host Configs
      ##
  
      #include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites-enabled/*;
  }
  </code></pre>
  <p>【myapp-unicorn】（/etc/nginx/site-enabled/myapp-unicorn）</p>
  <pre><code>upstream myapp.com {
      #my rails app
      server unix:/var/www/rails/myapp/tmp/sockets/unicorn.sock      fail_timeout=0;
  }
  
  server {
      listen 80;
      server_name myapp.com;
      location / {
          proxy_redirect off;
          proxy_set_header Host               $host;
          proxy_set_header X-Real-IP          $remote_addr;
          proxy_set_header X-Forwarded-Host   $host;
          proxy_set_header X-Forwarded-Server $host;
          proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
          client_max_body_size 35M;
          proxy_pass http://myapp.com;
      }
  }
  </code></pre>
  <p>【unicorn.rb】（/var/www/rails/myapp/config/unicorn.rb）</p>
  <pre><code>worker_processes 2
  
  listen File.expand_path('tmp/sockets/unicorn.sock', ENV['RAILS_ROOT'])
  
  stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
  stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
  
  preload_app true
  
  before_fork do |server, worker|
      defined?(ActiveRecord::Base) and     ActiveRecord::Base.connection.disconnect!
      old_pid = &quot;#{ server.config[:pid] }.oldbin&quot;
  
      unless old_pid == server.pid
          begin
              Process.kill :QUIT, File.read(old_pid).to_i
          rescue Errno::ENOENT, Errno::ESRCH
  
          end
      end
  end
  
  after_fork do |server, worker|
      defined?(ActiveRecord::Base) and    ActiveRecord::Base.establish_connection
  end
  </code></pre>
  <p>Thank you for your patience with my poor English.</p>
  <h1>Add</h1>
  <p>this is unicorn.log（/var/www/rails/myapp/log/unicorn.log）</p>
  <pre><code>I, [2015-09-05T18:17:20.590239 #10832]  INFO -- : Refreshing Gem list
  I, [2015-09-05T18:17:22.099133 #10832]  INFO -- : unlinking existing   socket=/var/www/rails/myapp/tmp/sockets/unicorn.sock
  I, [2015-09-05T18:17:22.099389 #10832]  INFO -- : listening on addr=/var/www/rails/myapp/tmp/sockets/unicorn.sock fd=11
  I, [2015-09-05T18:17:22.115503 #10832]  INFO -- : master process ready
  I, [2015-09-05T18:17:22.118878 #10836]  INFO -- : worker=0 ready
  I, [2015-09-05T18:17:22.127008 #10839]  INFO -- : worker=1 ready
  </code></pre>
  <p>this is nginx.log（/var/log/nginx/error.log）</p>
  <p>The nginx log is none...</p>