gpt4 book ai didi

node.js - AWS EC2 端口 80 连接被拒绝

转载 作者:行者123 更新时间:2023-12-02 19:14:39 26 4
gpt4 key购买 nike

我正在尝试在 aws EC2 上运行 Node js 服务器
我的 docker 文件:

FROM node:lts-alpine

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 80

CMD ["node", "server.js"]
在我的 server.js是一个监听 80 端口的快速网络服务器。
我将端口 80 包含在入站规则中:
security rules
但是,当我尝试打开公共(public) DNS 或关联域时,我仍然得到以下信息:
connection refused image
任何想法我做错了什么?

最佳答案

看来您的容器的 80端口未分配给主机 '运动。 EXPOSE指令不会为您执行此操作。来自 Docker docs :

The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.

关于node.js - AWS EC2 端口 80 连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64111402/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com