Django + Nginx + uWSGI = 504网关超时 [英] Django+Nginx+uWSGI = 504 Gateway Time-out

查看:149
本文介绍了Django + Nginx + uWSGI = 504网关超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Ubuntu 10.04,Django 1.3,Nginx 0.8.54和uWSGI 0.9.7.

I am running Ubuntu 10.04, Django 1.3, Nginx 0.8.54 and uWSGI 0.9.7.

Nginx和uWSGI都加载没有错误.但是,当您访问我的网站时,它坐了很长时间,然后最终加载了"504网关超时"错误.

Both Nginx and uWSGI load without error. However, when you access my site, it sits for a LONG time and then eventually loads a "504 Gateway Time-out" error.

这是我的Nginx虚拟主机conf文件:

Here is my Nginx Virtual Host conf file:

server {
listen          80;
server_name     www.mysite.com mysite.com;
error_log       /home/mysite/log/error.log;
access_log      /home/mysite/log/access.log;

location / {
    auth_basic  "Restricted";
    auth_basic_user_file    /home/mysite/public/passwd;
    include uwsgi_params;
    uwsgi_pass unix:///home/mysite/public/myapp.sock;
}

location /media {
    alias /home/mysite/public/myapp/media;
}


error_page  401  /coming_soon.html;

location /coming_soon.html {
    root /home/mysite/public/error_pages/401;
}

location /401/images {
    alias /home/mysite/public/error_pages/401/images;
}

location /401/style {
    alias /home/mysite/public/error_pages/401/style;
}

}

我的网站日志显示如下:

My site log shows this:

SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / !!!

我的错误日志显示如下:

My error log show this:

upstream timed out (110: Connection timed out) while reading response header from upstream

我在该服务器上还有另外两个站点,它们的配置相同,并且它们完全加载.

I have two other sites on this server with the same configuration and they load PERFECTLY.

还有其他人遇到过这个问题吗?这里有几个线程与我的问题类似,我尝试了其中的几种解决方案,但似乎无济于事.

Has anyone else encountered this problem? There are several threads on here that are similar to my issue and I've tried several of those solutions but nothing seems to work.

预先感谢您的帮助!

推荐答案

当请求超出NGINX uwsgi_read_timeout 设置时,将产生该错误.NGINX超过此限制后,它将关闭套接字,然后uWSGI尝试写入已关闭的套接字,从而产生您从uWSIG中看到的错误.

That error is produced when requests exceed the NGINX uwsgi_read_timeout setting. After NGINX exceeds this limit it closes the socket and then uWSGI tries to write to the closed socket, producing the error that you see from uWSIG.

确保您的NGINX超时至少与uWSGI超时(HARAKIRI_TIMEOUT)一样.

Make sure your NGINX timeouts are at least as high as uWSGI timeouts (HARAKIRI_TIMEOUT).

这篇关于Django + Nginx + uWSGI = 504网关超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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