简体   繁体   English

AWS OpsWorks:成功的Ruby on Rails默认层部署在浏览器中显示404错误

[英]AWS OpsWorks: Successful Ruby on Rails default layer deployment shows 404 error in browser

Didn't deployed Rails application in AWS OpsWorks. 未在AWS OpsWorks中部署Rails应用程序。 Totally confused how to do this! 完全混淆了如何做到这一点! Could anyone tell me how many instance required to deploy a RoR application? 谁能告诉我部署RoR应用程序需要多少实例?

I have created "Rails App Server" instance and it's looks fine. 我创建了“Rails App Server”实例,它看起来很好。 And here I used nginx and Unicorn as Rails Stack. 在这里我使用nginx和Unicorn作为Rails Stack。 在此输入图像描述

After that I've added a application from a git repo. 之后我从git repo添加了一个应用程序。 Then deployed that application. 然后部署该应用程序。 And logs showing it's deployed successfully. 并显示已成功部署的日志。

But in Public IP it's showing 404 Not Found Error - nginx ! 但在公共IP中,它显示404 Not Found Error - nginx

Any help would be appreciable. 任何帮助都会很明显。

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. 我遇到了这个问题,结果证明在部署期间没有删除默认的虚拟主机/etc/nginx/sites-enabled/000-default符号链接。

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 404实际上是nginx正在查找默认虚拟主机中的任何内容的公共根,如/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. 更糟糕的是,它在每次OpsWorks部署之后都会回来。 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 . 为了使修复可持续和自动化,我为Rails App Server层的Deploy生命周期事件添加了一个自定义配方,称为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

Check process list for unicorn and its log files. 检查unicorn及其日志文件的进程列表。 Deployment doesn't fail for some reason if unicorn master process doesn't start. 如果unicorn主进程没有启动,部署不会因某些原因而失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM