I had this issue, and it turned out that the default virtual host /etc/nginx/sites-enabled/000-default
symbolic link was not getting removed during deployment.
The 404 was actually nginx looking for a public root of whatever was in the default virtual host, as seen in /var/logs/nginx/error.log
2015/12/23 21:46:05 [error] 3839#0: *15 "/var/www/nginx-default/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: rails-app1, request: "GET / HTTP/1.1", host: "localhost"
Worse, it comes back after every OpsWorks deployment. Removing that link fixed the problem for me.
To make the fix sustainable and automated, I added a custom recipe to the Deploy lifecycle event for the Rails App Server layer, called custom-cookbook::delete-default-site
. The recipe looks like this:
file '/etc/nginx/sites-enabled/000-default' do
action :delete
end
service 'nginx' do
action :reload
end