【问题标题】:Receiving error 502 BAD CONNECTION nginx when deploying django app on Google app engine在 Google 应用引擎上部署 django 应用时收到错误 502 BAD CONNECTION nginx
【发布时间】:2021-07-06 10:47:59
【问题描述】:

我一直在尝试访问我的 django 网站,但每次都遇到相同的 502 BAD CONNECTION nginx 错误,我不知道如何解决它。

当我使用 py.manager runserver 运行程序时,它运行得非常好,但是我只在运行gcloud app deploy 时收到一个错误,查看日志我没有收到任何错误,只有一个警告说明Container called exit(1).

我尝试了 Google 网站上的一种解决方案:https://cloud.google.com/endpoints/docs/openapi/troubleshoot-response-errors,然后我将 resources: memory_gb: 4 添加到了我的 app.yaml 文件中,但最终还是出现了错误。

我不确定这对我的 app.yaml 有多大帮助,目前看起来像这样:

runtime: python39

handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
  static_dir: static/

# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
  script: auto

resources:
  memory_gb: 4

我的 gcloudignore 看起来像这样:

# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
secret_variables.py
.venv
Pipfile
Pipfile.lock

# Python pycache:
__pycache__/
# Ignored by the build system
/setup.cfg

提前感谢您的帮助

【问题讨论】:

  • 你有你想要部署在 github 某处的代码吗?
  • @jabbson,是的,链接如下:github.com/yousefsaid/test
  • 我从 pip 文件中添加了一些要求,我刚刚意识到有些安装是重叠的
  • 您在需求中缺少 django-filter
  • 我什至没有意识到,谢谢你的帮助@jabbson!

标签: django nginx google-app-engine google-cloud-platform error-handling


【解决方案1】:

运行 pip install -r requirements.txt 后克隆并尝试在本地运行代码。这是我得到的错误:

ModuleNotFoundError: No module named 'django_filters'

这意味着需要在将代码部署到 GAE 之前添加此要求。

django-filter 添加到 requirements.txt 文件以修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-14
    • 2016-09-28
    • 2020-10-31
    • 2021-10-02
    • 2018-08-22
    • 2013-07-16
    • 2021-06-22
    • 1970-01-01
    相关资源
    最近更新 更多