Docker 在 Elastic Beanstalk 上 - connect() 在连接到上游时失败(111:连接被拒绝)
Docker on Elastic Beanstalk - connect() failed (111: Connection refused) while connecting to upstream
我正在尝试 运行 AWS Elastic Beanstalk 上的一个简单注册 Flask 应用程序(此应用程序:https://github.com/jay3dec/PythonFlaskMySQLApp---Part-1)连接到托管在 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"]
如果您可以将 Dockerfile 添加到存储库,我可以查看它
这是一个端口和安全防火墙问题。在您的安全组中向世界开放端口 3306 和 5000。它将正常运行。
我正在尝试 运行 AWS Elastic Beanstalk 上的一个简单注册 Flask 应用程序(此应用程序:https://github.com/jay3dec/PythonFlaskMySQLApp---Part-1)连接到托管在 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"]
如果您可以将 Dockerfile 添加到存储库,我可以查看它
这是一个端口和安全防火墙问题。在您的安全组中向世界开放端口 3306 和 5000。它将正常运行。