【问题标题】:How can I resolve DNS issues with Elastic Beanstalk, Nginx?如何解决 Elastic Beanstalk、Nginx 的 DNS 问题?
【发布时间】:2022-01-26 02:24:27
【问题描述】:

我正在尝试使用 Elastic Beanstalk 上的 Docker 启动并运行一个超级简单的 Flask 服务器。当我导航到与 EB 环境关联的域时,我看到的只是一个巨大的 502 Bad Gateway Error。

再深入一点,我在 EB 的 Nginx 日志中看到以下错误:

2021/12/26 01:00:24 [error] 16944#16944: *682 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.23.137, server: , request: "GET / HTTP/1.1", upstream: "http://172.17.0.2:5000/", host: "172.31.1.207"

eb-stdouterr.log 中,它报告服务器已启动并正在运行:

web_1  |  * Serving Flask app 'app' (lazy loading)
web_1  |  * Environment: production
web_1  |    WARNING: This is a development server. Do not use it in a production deployment.
web_1  |    Use a production WSGI server instead.
web_1  |  * Debug mode: on
web_1  |  * Running on all addresses.
web_1  |    WARNING: This is a development server. Do not use it in a production deployment.
web_1  |  * Running on http://172.24.0.2:5000/ (Press CTRL+C to quit)

我找到了与 EC2 实例关联的公共 IP 地址,并且我实际上能够使用 curl 查询到预期结果,所以感觉这是一个 DNS 问题。有什么提示或建议吗?我真的不知道如何进一步调试。

配置:

  • AWS Linux 2
  • Docker Python 映像 3.9-buster
  • Flask 服务器

编辑:从 AWS documentation 看来,使用 docker-compose 意味着您不应该使用 Nginx? 我去禁用了它,但我仍然遇到 502 Bad Gateway 问题和没有相关的错误日志。

这是我的Dockerfile

# syntax=docker/dockerfile:1
FROM python:3.9-buster
COPY . /code
WORKDIR /code
COPY requirements.txt requirements.txt
RUN apt-get update -y && \
    apt-get install -y python-pip python-dev && \
    pip install --upgrade pip && \
    pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD python app.py

这是我的docker-compose.yml

version: "3.9"
services:
  web:
    build: .
    ports:
      - "5000:5000"
    volumes:
      - .:/code

请帮忙,提前谢谢:D

【问题讨论】:

标签: nginx dns amazon-elastic-beanstalk


【解决方案1】:

我通过完全删除我的 docker-compose.yml 文件解决了这个问题。我认为必须完成一些配置才能解决代理配置或(也许?)使用自定义 docker 映像。不确定是哪个问题,但只是使用我的根目录中的 Dockerfile 是有效的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-02
    • 2020-11-10
    • 2017-12-30
    • 2019-08-11
    • 2014-10-19
    • 1970-01-01
    • 2016-06-11
    • 2016-09-25
    相关资源
    最近更新 更多