【发布时间】:2021-09-11 21:03:55
【问题描述】:
我正在尝试通过 Elastic Beanstalk 将我的应用程序上传到 AWS(在 64 位 Amazon Linux 2 上运行的 Python 3.8)。我的应用程序是使用 Django 3.0 开发的。操作系统是 Ubuntu 20.04。
我从一个空的 Django 项目开始,通过绿色状态健康检查可以正常工作,并且 Django 管理员可以正常工作。当我从我的应用程序添加文件时,它会引发 502 bad gateway 错误。我花了很多天试图解决这个问题,但没有成功。
var/log/nginx/error/log:
2021/06/29 15:29:42 [error] 4854#4854: *4084 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.20.250, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "35.176.238.136"
django.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: FFfF_project.wsgi:application
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: FFfF_project.settings
PYTHONPATH: "/var/app/current:"
01_packages.config
packages:
yum:
python3-devel: []
mariadb-devel: []
requirements.txt
django==3.0
django-crispy-forms==1.9.2
Pillow==8.2.0
gunicorn==20.0.4
mysqlclient==1.4.6
config.yml
branch-defaults:
master:
environment: FFfF-env
group_suffix: null
environment-defaults:
FFfF-env:
branch: null
repository: null
global:
application_name: FFfF_project
branch: null
default_ec2_keyname: ff-KeyPair
default_platform: Python 3.8 running on 64bit Amazon Linux 2
default_region: eu-west-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: git
workspace_type: Application
我认为错误与 nginx.config 文件有关,但我找不到该文件进行编辑或修改。它不在我的系统上,我无法通过 Elastic Beanstalk 控制台找到它。我的广泛搜索导致了许多使用早期版本的 AWS 平台的解决方案,但在 Amazon Linux 2 上几乎没有。一种解决方案似乎是使用带有 .platform/ 的配置文件,这仍然需要访问 nginx/config 文件来修改或过度写作,但如果我找不到 nginx.config 文件,我会很难过!!!
根据我了解的各种文档,我不需要安装 nginx,因为它是 Elastic Beanstalk 不可或缺的一部分,也许我错了!
【问题讨论】:
-
您找到解决问题的方法了吗?顺便说一句,我将这里作为答案而不是评论留下,因为我没有足够的代表发表评论。
标签: python django amazon-web-services nginx