Nginx 502错误网关-Django-Gunicorn-运行MySQL报告(存储过程)的时间超过30秒

问题描述:

我在AWS上有Django,Nginx,Gunicorn和MySQL.

I have a Django, Nginx, Gunicorn, and MySQL on AWS.

运行来自django的回发,该回发调用了需要30秒钟以上才能完成的存储过程,从而导致返回"502 Bad Gateway" nginx/1.4.6(Ubuntu).

Running a postback from django which calls a stored procedure that takes longer than 30 seconds to complete causes a return of "502 Bad Gateway" nginx/1.4.6 (Ubuntu).

肯定看起来像是超时问题,并且此帖子应该可以解决该问题.

It sure looks like a timeout issue and that this post should resolve it.

但是可惜,它似乎没有用.

But alas, it doesn't seem to be working.

这是我的gunicorn.conf文件:

Here is my gunicorn.conf file:

description "Gunicorn application server handling formManagement django app"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
setuid ubuntu
setgid www-data
chdir /home/ubuntu/AARC-ServiceManager/ServerSide/formManagement

exec ve/bin/gunicorn --timeout 300 --workers 3 --bind unix:/home/ubuntu/AARC-ServiceManager/ServerSide/formManagement/formManagement.sock formManagement.wsgi:application

还有我的Nginx.conf:

And my Nginx.conf:

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

events {
                worker_connections 768;
                # multi_accept on;
}

http {

                ##
                # Basic Settings
                ##

                # set client body size (max http request size) #
                client_max_body_size 50M;

                #upping the timeouts to allow time for the DB to return from a long running sproc
                proxy_connect_timeout 300s;
                proxy_read_timeout 300s;

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

                # server_names_hash_bucket_size 64;
                # server_name_in_redirect off;

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

                ##
                # Logging Settings
                ##

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

                ##
                # Gzip Settings
                ##

                gzip on;
                gzip_disable "msie6";


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


有什么想法吗?

更新: 这是nginx错误日志中的错误: [错误] 14316#0:* 13上游过早关闭连接,同时从上游读取响应标头...

UPDATE: This is the error in the nginx error log: [error] 14316#0: *13 upstream prematurely closed connection while reading response header from upstream ...

我找到了解决方法!

我正在更新错误的gunicorn.conf文件.

I was updating the wrong gunicorn.conf file.

我将配置文件保存到我的源代码管理中,当我在服务器中时,正在更新该文件.

I saved to config file to my source control and when I was in the server, was updating that file.

但是,我需要在以下位置更改文件

However, I needed to be changing the file at location:

/etc/init/gunicorn.conf

...,我上了一课,关于服务器上有多个配置文件.

... and I learned a lesson about having more than one config file on the server.

感谢所有提供帮助的人.

Thanks all who were offering help.