部署django项目出现502 Bad Gateway错误。怎么解决,谢谢

新手上路,请多包涵

我部署了个Django项目,输入ip之后,一直提示我502 Bad Gateway,是我配置文件的问题吗
etc/nginx/sites-enabled/fefault:


server {
        listen 80;
        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name 47.101.157.128;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                include uwsgi_params;
                uwsgi_pass 47.101.157.128:8000;
        }
        location /static{
                alias /var/www/sscc2019/static/;
        }

uwsgi.ini:

[uwsgi]
socket=47.101.157.128:8000
chdir=home/sscc/sscc2019
wsgi-file=sscc2019/wsgi.py
processes=4
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uswgi.log
module=sscc2019.wsgi:application
vacuum=true
virtualenv=/home/ssccenv
#plugin=python3

这是我的配置文件,我用的是阿里云的服务器

阅读 7.4k
2 个回答
新手上路,请多包涵

楼主解决好了吗?我也是报这个错

nginx配置代理最好指定好协议:uwsgi_pass http://47.101.157.128:8000;
如果nginx配置没问题的话,检查uwsgi是否正常侦听8000: lsof -i:8000可以检查。
uwsgi配置里面的最好指定绝对路径,例如:chdir=home/sscc/sscc2019 => chdir=/home/sscc/sscc2019
这里很明显,你本机uwsgi是不能正常工作的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题