【问题标题】:502 Bad Gateway nginx/1.18.0 (Ubuntu) Django Digital ocean502 Bad Gateway nginx/1.18.0 (Ubuntu) Django 数字海洋
【发布时间】:2022-11-22 23:29:40
【问题描述】:

我想用 Ubuntu 和 Digital Ocean 部署我的 django 项目。这不是我第一次这样做,但现在我一直收到这个错误,我不知道是什么原因造成的。我用这个视频作为过程指南:https://www.youtube.com/watch?v=US9BkvzuIxw。这真的很烦人,因为我收到的唯一消息是“502 Bad Gateway nginx/1.18.0 (Ubuntu)”,而我在互联网上找到的解决它的方法不起作用。我运行的所有 nginx 测试都说它工作正常。 这是我认为错误必须是的代码:

/etc/nginx/sites-available/locallibrary

server {
        server_name vvmwp.nl;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
                root /home/sammy/locallibrary;
        }

        location / {
                include proxy_params;
                proxy_pass http://unix:/run/gunicorn.sock;
        }
}

/etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=sammy
Group=sammy
EnvironmentFile=/home/sammy/locallibrary/env
WorkingDirectory=/home/sammy/locallibrary
ExecStart=/home/sammy/env/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          locallibrary.wsgi:application

[Install]
WantedBy=multi-user.target

/etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

提前致谢

【问题讨论】:

  • 在您的 nginx 和 gunicorn 文件中将名称 sammy 替换为您自己的用户名(除非恰好是 sammy :)。您可能需要重新加载服务,sudo systemctl daemon-reload。祝你好运!
  • 我的用户名是 sammy,我已经为 nginx 运行了所有重新加载和重新启动。我认为错误必须在其他任何地方。不管怎么说,还是要谢谢你

标签: python django nginx bad-gateway


【解决方案1】:

我遇到了同样的问题,但没有任何效果,但后来我杀死了我的前一个端口 8080 并再次安装了 nginx 和 pm2,一切正常。

【讨论】:

    猜你喜欢
    • 2014-12-20
    • 2021-01-25
    • 2017-09-20
    • 2022-08-16
    • 2023-03-20
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    相关资源
    最近更新 更多