Elastic Beanstalk上的Docker - 连接到上游时connect()失败(111:连接被拒绝)

时间:2016-07-17 15:42:44

标签: amazon-web-services nginx docker elastic-beanstalk amazon-rds

我正在尝试在AWS Elastic Beanstalk(此应用程序:https://github.com/jay3dec/PythonFlaskMySQLApp---Part-1)上运行一个简单的注册Flask应用程序,该应用程序连接到AWS RDS上托管的外部MySQL数据库。

该应用程序在本地运行完美(即使我从本地应用程序连接到AWS RDS)。

但是当我在命令行中打开eb时,我得到:

502 Bad Gateway

nginx/1.8.1

当我创建eb时,我收到了警告:

WARN    Only one EXPOSE directive is allowed, using the first one: 3306

因为在我的Dockerfile中,我有:

EXPOSE 3306
EXPOSE 5000

对于eb日志,我有:

/var/log/nginx/error.log
-------------------------------------
2016/07/17 15:18:06 [warn] 8928#0: duplicate MIME type "text/html" in /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf:11
2016/07/17 15:18:06 [warn] 8934#0: duplicate MIME type "text/html" in /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf:11
2016/07/17 15:20:54 [error] 8937#0: *33 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.6.93, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.17.0.2:3306/favicon.ico", host: "flasksecgroup-dev.us-east-1.elasticbeanstalk.com", referrer: "http://flasksecgroup-dev.us-east-1.elasticbeanstalk.com/"

我的Dockerfile是:

FROM ubuntu:latest

RUN apt-get update -y
RUN apt-get install -y python-pip libmysqlclient-dev python-dev build-    essential
 COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt

# Expose
EXPOSE 3306
EXPOSE 5000

ENTRYPOINT ["python"]
CMD ["app.py"]

2 个答案:

答案 0 :(得分:1)

这是端口和安全防火墙问题。在您的安全组中打开端口3306和5000到world。它没有任何错误。

答案 1 :(得分:-2)

如果您可以将Dockerfile添加到存储库,我可以检查它