【发布时间】:2014-11-15 05:48:22
【问题描述】:
我在我的实时服务器中使用带有 django 和 nginx 的 uwsgi,但它给了我一个错误,即“上游过早关闭连接 nginx uwsgi”。谷歌搜索后,我发现这不是 nginx 的问题,而不是 uwsgi 的问题。因此我检查了我的 uwsgi 日志并发现了
return render(request, 'webclient/404.html') File
"/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py",
line 49, in render
context_instance = RequestContext(request, current_app=current_app) File
"/usr/local/lib/python2.7/dist-packages/django/template/context.py",
line 179, in __init__
self.update(processor(request)) File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py",
line 24, in _wrapped_view
if test_func(request.user): AttributeError: 'WSGIRequest' object has no attribute 'user' [pid: 10878|app: 0|req: 6/7] 125.64.35.67 ()
{38 vars in 717 bytes} [Fri Nov 14 10:13:10 2014] GET
/zc/chs/img/body.png =>generated 0 bytes in 3 msecs (HTTP/1.1 500) 0
headers in 0 bytes (0 switches on core 0) [pid: 10878|app: 0|req: 7/8]
127.0.0.1 () {30 vars in 414 bytes} [Fri Nov 14 22:56:41 2014] GET / => generated 0 bytes in 3 msecs (HTTP/1.1 302) 3 headers in 126 bytes (1 switches on core 0)
有人可以在这方面帮助我吗?
【问题讨论】:
-
你写的是test_func吗?这什么时候发生?
request对象缺少用户属性 -
不,我没有写那个 test_func。当我尝试从浏览器测试我的 nginx 和 uwsgi 配置是否正确时。
-
现在我通过将 wsgi 请求传递给 apache 来使用两个应用程序服务器(如 apache 和 nginx)来管理它。 Nginx 用于提供静态文件,apache 用于 wsgi 请求。
标签: python django python-2.7 nginx uwsgi