当DEBUG = False时,nginx,uwsgi,DJango,502,“上游过早关闭的连接"; [英] nginx, uwsgi, DJango, 502 when DEBUG=False, "upstream prematurely closed connection"

查看:59
本文介绍了当DEBUG = False时,nginx,uwsgi,DJango,502,“上游过早关闭的连接";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用uwsgi且正在运行Django应用程序的nginx生产服务器,该服务器使用本教程).

I have a working nginx production server running a Django app, using uwsgi (set up with this tutorial).

nginx和uwsgi通过UNIX套接字进行通信.

nginx and uwsgi are communicating through a UNIX socket.

但是,当我在Django设置中打开 DEBUG = False 时,就会收到502错误.Nginx错误日志告诉我:

However, as soon as I turn DEBUG = False in my Django settings, I get a 502 error. The nginx error log tells me:

2015/09/08 10:37:51 [error] 940#0: *4 upstream prematurely closed connection while reading response header from upstream, client: myIP, server: mydomain.ca, request: "GET /quests/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/hackerspace.sock:", host: "myDomain"

如何防止套接字连接超时,为什么DEBUG = False会造成这种差异?

How can I prevent the socket connection from timing out, and why is DEBUG = False making this difference?

谢谢!

推荐答案

我找到了适合我的解决方案.我必须在Django的settings.py

I found the solution that works for me. I had to specify hosts for ALLOWED_HOSTS list in django's settings.py

ALLOWED_HOSTS = ['example.com','example.dev']

这篇关于当DEBUG = False时,nginx,uwsgi,DJango,502,“上游过早关闭的连接";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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