【问题标题】:Error on EB AWS - 502 Bad Gateway nginx/1.18.0EB AWS 上的错误 - 502 Bad Gateway nginx/1.18.0
【发布时间】:2021-01-25 17:07:13
【问题描述】:

我在 AWS 中运行的 Node 应用程序存在问题。直到今天一切正常。

在没有对应用进行任何新部署的情况下,当我尝试访问 URL 时收到此 502 错误。

我检查了 nginx 日志,我得到了这个:

2020/10/11 01:24:55 [error] 4735#0: *1 connect() failed (111: Connection refused) while connection to upstream, server: , request: "GET /favicon.ico HTTP/ 1.1”,上游:“http://127.0.0.1:8080/favicon.ico”,主机:“mydomain.com”,引荐来源:“mydomain.com”

我尝试使用新的入站规则创建一个新的安全组,但没有成功,我缺少 EB 配置的“新”更新吗?

提前致谢。

【问题讨论】:

  • 如果你 ssh 到 EB 实例,你能从里面 curl 你的应用程序吗?
  • Connection refused 通常表示服务器没有监听目标端口。你的节点应用程序还在运行吗?
  • 是的@Marcin,我可以卷曲,但我得到了同样的错误: 502 Bad Gateway

    502 网关错误


    nginx/1.18.0
  • 是的@gusto2,它正在运行,状态为“Ok”
  • 来自 nginx 的消息和日志表明 nginx 正在尝试连接到localhost:8080,并且服务器告诉没有人在那里收听。 Marcin 在询问您是否可以直接卷曲后端(端口 8080)而不是 nginx 代理

标签: node.js amazon-web-services amazon-elastic-beanstalk


【解决方案1】:

enter image description here如果你在 eb 上使用 python > 3.6。然后 eb 将使用 gunicorn 运行您的 django 应用程序。 因此,您需要使用 pip install gunicorn 安装 gunicorn 并在 requirements.txt 中使用 pip freeze requirements.txt 提及它,最重要的是您需要在 manage.py 所在的项目根目录中创建“Procfile”。 “Procfile”将没有扩展名。 “Procfile”内容如下: 网络:gunicorn --bind :8000 --workers 3 --threads 2 ebdjango.wsgi:application 代替 ebdjango 放置项目名称并使用 eb deploy 进行部署。 谢谢!

【讨论】:

    【解决方案2】:

    我和你在同一时间遇到了完全相同的问题。我的解决方案是将程序的开头从 index.js 删除到 app.js。之后一切正常。由于某种原因,aws 不再启动 index.js 文件。

    【讨论】:

      猜你喜欢
      • 2022-11-22
      • 2018-04-23
      • 2021-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 2018-11-12
      • 2019-09-05
      相关资源
      最近更新 更多