title: Apache2 Ubuntu Default Page Showing Up
body: <p>Have been working with Rails 5 and setting up everything through Vagrant. I have successfully been able to get my site working through Nginx and Webrick. When I try with Unicorn, it shows me the Apache2 default page. I removed the default in <code>sites-available</code> and created one under <code>sites-enabled</code> which is linked to <code>nginx.conf</code>.</p>
  
  <p><strong>Here is my <code>nginx.conf</code> file:</strong></p>
  
  <pre><code>upstream unicorn {
    server unix:/tmp/unicorn.mysiteNginx.sock fail_timeout=0;
  }
  
  server {
    listen 80 default deferred;
    # server_name projectname.com;
    root /vagrant/public;
    try_files $uri/home.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 10;
    }
  </code></pre>
  
  <p><strong><code>unicorn.rb</code></strong> file:</p>
  
  <pre><code>working_directory "/vagrant"
  pid "/vagrant/tmp/pids/unicorn.pid"
  stderr_path "/vagrant/log/unicorn.log"
  stdout_path "/vagrant/log/unicorn.log"
  
  listen "/tmp/unicorn.mysiteNginx.sock"
  worker_processes 2
  timeout 30
  </code></pre>
  
  <p><strong><code>unicorn_init.sh</code> file:</strong></p>
  
  <pre><code>#!/bin/sh
  set -e
  # Example init script, this can be used with nginx, too,
  # since nginx and unicorn accept the same signals
  
  # Feel free to change any of the following variables for your app:
  # Remember -E production flag for production &amp; sudo -c "$CMD" - user so it's not run as root!
  TIMEOUT=${TIMEOUT-60}
  APP_ROOT=/vagrant
  PID=$APP_ROOT/tmp/pids/unicorn.pid
  CMD="/home/vagrant/.rvm/bin/ruby-2.3.1_unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
  action="$1"
  set -u
  
  old_pid="$PID.oldbin"
  
  cd $APP_ROOT || exit 1
  
  sig () {
          test -s "$PID" &amp;&amp; kill -$1 `cat $PID`
  }
  
  oldsig () {
          test -s $old_pid &amp;&amp; kill -$1 `cat $old_pid`
  }
  
  case $action in
  start)
          sig 0 &amp;&amp; echo &gt;&amp;2 "Already running" &amp;&amp; exit 0
          su -c "$CMD" - vagrant
          ;;
  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"
          su -c "$CMD" - vagrant
          ;;
  upgrade)
          if sig USR2 &amp;&amp; sleep 2 &amp;&amp; sig 0 &amp;&amp; oldsig QUIT
          then
                  n=$TIMEOUT
                  while test -s $old_pid &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_pid
                  then
                          echo &gt;&amp;2 "$old_pid still exists after $TIMEOUT seconds"
                          exit 1
                  fi
                  exit 0
          fi
          echo &gt;&amp;2 "Couldn't upgrade, starting '$CMD' instead"
          su -c "$CMD" - vagrant
          ;;
  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>Before submitting this question, I did some research on stack overflow and did some troubleshooting with similar question but no success so far. Any help would be appreciated!</p>
  
  <p><strong>---UPDATE 1---</strong></p>
  
  <p>This is what shows in <code>error.log</code> when I do <code>sudo service unicorn restart</code>:</p>
  
  <pre><code>017/08/07 22:41:17 [notice] 2387#2387: signal process started
  2017/08/07 22:41:18 [emerg] 2391#2391: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2017/08/07 22:41:18 [emerg] 2391#2391: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2017/08/07 22:41:18 [emerg] 2391#2391: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2017/08/07 22:41:18 [emerg] 2391#2391: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2017/08/07 22:41:18 [emerg] 2391#2391: bind() to 0.0.0.0:80 failed (98: Address already in use)
  2017/08/07 22:41:18 [emerg] 2391#2391: still could not bind()
  </code></pre>
  
  <p><strong>---UPDATE 2---</strong></p>
  
  <p>Log after <code>sudo lsof -i:80</code></p>
  
  <pre><code>COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  nginx   1854     root    6u  IPv4  11471      0t0  TCP *:http (LISTEN)
  nginx   1855 www-data    6u  IPv4  11471      0t0  TCP *:http (LISTEN)
  </code></pre>