Django+Nginx+uWSGI = 504 网关超时

发布于 2024-11-19 12:25:54 字数 1290 浏览 1 评论 0原文

我正在运行 Ubuntu 10.04、Django 1.3、Nginx 0.8.54 和 uWSGI 0.9.7。

Nginx 和 uWSGI 加载都没有错误。但是,当您访问我的网站时,它会停留很长时间,然后最终加载“504 网关超时”错误。

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

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;
}

}

我的站点日志显示了这一点:

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

我的错误日志显示了这一点:

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

我在此服务器上还有另外两个具有相同配置的站点,并且它们加载完美。

还有其他人遇到过这个问题吗?这里有几个线程与我的问题类似,我已经尝试了其中的几个解决方案,但似乎没有任何效果。

预先感谢您的帮助!

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

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.

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.

Thank you in advance for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

━╋う一瞬間旳綻放 2024-11-26 12:25:54

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

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

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.

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

煮酒 2024-11-26 12:25:54

unix:///home/mysite/public/myapp.sock;
语法不正确,使用如下:

unix:/home/mysite/public/myapp.sock;

unix:///home/mysite/public/myapp.sock;
syntax not correct, use like this:

unix:/home/mysite/public/myapp.sock;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文