uwsgi + nginx +烧瓶:上游过早关闭 [英] uwsgi + nginx + flask: upstream prematurely closed

查看:162
本文介绍了uwsgi + nginx +烧瓶:上游过早关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在烧瓶上创建了一个端点,该端点从数据库查询(远程数据库)生成电子表格,然后将其作为下载文件发送到浏览器中. Flask不会抛出任何错误. Uwsgi没有抱怨.

I created an endpoint on my flask which generates a spreadsheet from a database query (remote db) and then sends it as a download in the browser. Flask doesn't throw any errors. Uwsgi doesn't complain.

但是当我检查nginx的error.log时,我看到了很多

But when I check nginx's error.log I see a lot of

2014/12/10 05:06:24 [错误] 14084#0:* 239436提前过早 从客户端读取响应标头时关闭连接: 34.34.34.34,服务器:me.com,请求:"GET/download/export.csv HTTP/1.1",上游:"uwsgi://0.0.0.0:5002",主机:"me.com",引荐来源网址: " https://me.com/download/export.csv "

2014/12/10 05:06:24 [error] 14084#0: *239436 upstream prematurely closed connection while reading response header from upstream, client: 34.34.34.34, server: me.com, request: "GET /download/export.csv HTTP/1.1", upstream: "uwsgi://0.0.0.0:5002", host: "me.com", referrer: "https://me.com/download/export.csv"

我像部署uwsgi

uwsgi --socket 0.0.0.0:5002 --buffer-size=32768 --module server --callab app

我的nginx配置:

server {
     listen 80;
     merge_slashes off;
     server_name me.com www.me.cpm;

     location / { try_files $uri @app; }
       location @app {
          include uwsgi_params;
          uwsgi_pass 0.0.0.0:5002;
          uwsgi_buffer_size 32k;
          uwsgi_buffers 8 32k;
          uwsgi_busy_buffers_size 32k;
     }

}

server {
      listen 443;
      merge_slashes off;
      server_name me.com www.me.com;

    location / { try_files $uri @app; }
       location @app {
          include uwsgi_params;
          uwsgi_pass 0.0.0.0:5002;
          uwsgi_buffer_size 32k;
          uwsgi_buffers 8 32k;
          uwsgi_busy_buffers_size 32k;
       }
}

这是nginx还是uwsgi问题,还是两者都存在?

Is this an nginx or uwsgi issue, or both?

推荐答案

将nginx.conf更改为包含

Change nginx.conf to include

sendfile        on;
client_max_body_size 20M;
keepalive_timeout  0;

有关完整示例,请参见 uwsgi在亚马逊linux上的新贵

See self answer uwsgi upstart on amazon linux for full example

这篇关于uwsgi + nginx +烧瓶:上游过早关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆