错误:从上游读取响应头时上游过早关闭连接[uWSGI/Django/NGINX]

 温德军46867 发布于 2023-01-20 16:56

我目前总是在我的用户正在进行的查询中获得502 ...通常返回872行并在MySQL中运行2.07.然而,它返回了大量信息.(每行包含很多东西).有任何想法吗?

运行Django(tastypie Rest API),Nginx和uWSGI堆栈.

使用NGINX进行服务器配置

# the upstream component nginx needs to connect to
upstream django {
    server unix:///srv/www/poka/app/poka/nginx/poka.sock; # for a file socket
}

# configuration of the server
server {
    # the port your site will be served on
    listen  443;


    # the domain name it will serve for
    server_name xxxx; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 750M;   # adjust to taste

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /srv/www/poka/app/poka/nginx/uwsgi_params; # the uwsgi_params file you installed
    }
}

UWSGI配置

# process-related settings
# master
master          = true
# maximum number of worker processes
processes   = 2
# the socket (use the full path to be safe
socket          = /srv/www/poka/app/poka/nginx/poka.sock
# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true

pidfile = /tmp/project-master.pid # create a pidfile
harakiri = 120 # respawn processes taking more than 20 seconds
max-requests = 5000 # respawn processes after serving 5000 requests
daemonize = /var/log/uwsgi/poka.log # background the process & log
log-maxsize = 10000000
#http://uwsgi-docs.readthedocs.org/en/latest/Options.html#post-buffering
post-buffering=1
logto = /var/log/uwsgi/poka.log # background the process & log

Danack.. 12

这不太可能是nginx配置问题.

几乎可以肯定,后端实际上是崩溃(或者只是终止连接),而不是给出错误的响应.即错误消息告诉你问题是什么,但你正在寻找错误的地方来解决它.

你没有提供足够的信息来让我们知道究竟是什么问题,但如果我不得不猜测:

它通常返回872行,并在MySQL中运行2.07.然而,它返回了大量信息.

它要么在某个地方超时,要么耗尽内存.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有