[英]AWS Fargate 502 Bad Gateway after initial load
I've been following a Fargate/docker tutorial here: https://medium.com/containers-on-aws/building-a-socket-io-chat-app-and-deploying-it-using-aws-fargate-86fd7cbce13f我一直在关注 Fargate/docker 教程: https://medium.com/containers-on-aws/building-a-socket-io-chat-app-and-deploying-it-using-aws-fargate- 86fd7cbce13f
Here is my Dockerfile这是我的 Dockerfile
FROM mhart/alpine-node:15 AS build
WORKDIR /srv
ADD package.json .
RUN yarn
ADD . .
FROM mhart/alpine-node:base-9
COPY --from=build /srv .
EXPOSE 3000
CMD ["node", "index.js"]
I have two Fargate stacks我有两个 Fargate 堆栈
production
was created from the AWS CloudFormation public-service template production
是从 AWS CloudFormation 公共服务模板创建的
chat
was created from the AWS CloudFormation public-vpc template with some parameter substitutions from the tutorial: chat
是从 AWS CloudFormation public-vpc 模板创建的,其中包含教程中的一些参数替换:
The production stack exposes a valid ExternalUrl output parameter生产堆栈公开了一个有效的 ExternalUrl output 参数
When I open the URL, I can see a successful initial load of the index当我打开 URL 时,可以看到索引的初始加载成功
But resources respond with a 502 (Bad Gateway)但资源以 502(坏网关)响应
And if I refresh the URL, the index throws the error as well如果我刷新 URL,索引也会抛出错误
I'm new to AWS and Fargate.我是 AWS 和 Fargate 的新手。 Are there server logs I should check?
是否有我应该检查的服务器日志? Could this be a problem with either of the templates (
public-vpc.yml
or public-service.yml
) that I used for setup?这可能是我用于设置的任何一个模板(
public-vpc.yml
或public-service.yml
)的问题吗? Any help is appreciated — thank you.任何帮助表示赞赏 - 谢谢。
Looks like your health checks are failing and so the instance is being stopped.看起来您的运行状况检查失败,因此正在停止实例。 You can validate that by navigating to
ECS -> Clusters -> (Cluster) -> (Service) -> Tasks -> Stopped
- this will show the list of containers that have recently been stopped and why.您可以通过导航到
ECS -> Clusters -> (Cluster) -> (Service) -> Tasks -> Stopped
来验证这一点 - 这将显示最近停止的容器列表及其原因。
I haven't dug through the CloudFormation, but I bet that the mapping of the Health Check to the container port is wrong.我还没有挖掘过 CloudFormation,但我敢打赌,健康检查到容器端口的映射是错误的。
Mystery solved.谜团已揭开。 Thank you @Marcin and @cynicaljoy for your help, @cynicaljoy, I checked the ECS cluster status.
谢谢@Marcin 和@cynicaljoy 的帮助,@cynicaljoy,我检查了ECS 集群状态。 but there was nothing out of the ordinary — the chat task was RUNNING.
但没有什么异常——聊天任务正在运行。
@Marcin, I followed your lead and re-created the stacks and app. @Marcin,我按照您的指示重新创建了堆栈和应用程序。 Now it works.
现在它起作用了。 My issue was neglecting to match up the correct regions in all of my AWS commands the first time around.
我的问题是第一次忽略了在我的所有 AWS 命令中匹配正确的区域。 Some were run with
us-west-1
and some with us-west-2
.有些使用
us-west-1
运行,有些使用us-west-2
运行。 Once I matched those up, the gateway problem went away.一旦我匹配了这些,网关问题就消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.