Nginx 烧瓶上游过早关闭连接

Nginx 烧瓶上游过早关闭连接,nginx,Nginx,请注意,我已经提到,但这并没有解决问题 正如您从nginx错误日志中看到的,我正在向/订单历史记录发送post请求。然后,这将运行一个SQL查询,该查询将花费大约一分钟的时间,但是,连接将提前关闭。当应用程序与flask测试服务器一起部署时,显然不会出现此问题,正如日志所指出的:) /var/log/nginx/error.log: 2018/05/30 15:34:04 [error] 12294#12294: *9 upstream prematurely closed connection

请注意,我已经提到,但这并没有解决问题

正如您从nginx错误日志中看到的,我正在向
/订单历史记录
发送post请求。然后,这将运行一个SQL查询,该查询将花费大约一分钟的时间,但是,连接将提前关闭。当应用程序与flask测试服务器一起部署时,显然不会出现此问题,正如日志所指出的:)

/var/log/nginx/error.log

2018/05/30 15:34:04 [error] 12294#12294: *9 upstream prematurely closed connection while reading response header from upstream, client: 192.168.96.116, server: alpha2, request: "POST /order-history HTTP/1.1", upstream: "http://unix:/home/hleggio/myproject/myproject.sock:/order-history", host: "alpha2:5000", referrer: "http://alpha2:5000/query-selection"
/etc/nginx//nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    fastcgi_read_timeout 99999;
    proxy_read_timeout 99999;
    # server_tokens off;



    client_max_body_size 20M;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites available/myproject

server {
    listen 5000;
    server_name alpha2;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/hleggio/myproject/myproject.sock;
        proxy_read_timeout 9999;
        proxy_connect_timeout 9999;
        proxy_request_buffering off;
        proxy_buffering off;
    }
}

我能够解决这个问题。这与我的NGINX配置无关

问题存在于我的Gunicorn配置文件中

在我的Gunicorn配置文件(
/etc/systemd/system/myproject.service
)中,我在我的
ExecStart
行中添加了以下内容:

--超时600

该文件现在如下所示:

[Unit]
Description=Gunicorn instance to serve myproject
After=network.target

[Service]
User=harrison
Group=www-data
WorkingDirectory=/home/harrison/myproject
Environment="PATH=/home/harrison/myproject/myprojectenv/bin"
ExecStart=/home/harrison/myproject/myprojectenv/bin/gunicorn --workers 3 --timeout 600 --bind unix:myproject.sock -m 007 wsgi:application

[Install]
WantedBy=multi-user.target