我在 Nginx 后面的远程服务器上安装了 django 1.3.
I have django 1.3 on the remote server behind Nginx.
如果我使用 apache + mod_wsgi 运行 django,我可以查看 apache 日志文件中的错误.没关系,但我想在控制台中使用.
If I run django with apache + mod_wsgi, I can watch errors in apache log files. It's ok but I'd like to have in console.
如果我运行 django 自己的开发服务器,只有当 DEBUG = False 时,我才会在控制台中收到堆栈跟踪错误.在调试模式控制台输出
If I run django own development server, I get errors with stacktrace in console only when DEBUG = False. In DEBUG mode console outputs
Exception happened during processing of request from (..., ...) Traceback (most recent call last): File "/usr/local/python/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock self.process_request(request, client_address) File "/usr/local/python/lib/python2.7/SocketServer.py", line 310, in process_request self.finish_request(request, client_address) File "/usr/local/python/lib/python2.7/SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/python/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 570, in __init__ BaseHTTPRequestHandler.__init__(self, *args, **kwargs) File "/usr/local/python/lib/python2.7/SocketServer.py", line 641, in __init__ self.finish() File "/usr/local/python/lib/python2.7/SocketServer.py", line 694, in finish self.wfile.flush() File "/usr/local/python/lib/python2.7/socket.py", line 301, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 32] Broken pipe我想弄清楚为什么?为什么 django 只是输出未命名的异常?为什么它依赖于 DEBUG 变量.
I want to figure out why? Why does django just output unnamed Exception? Why does it depend on DEBUG variable.
当我无法访问请求对象时,此错误主要发生在视图之外.所以我无法在中间件或使用日志处理程序中捕获它.
This errors occurs mostly outside views when I have no access to request object. So I can't catch it in middleware or using logging handler.
更新.我注意到如果我直接向 django 服务器请求,我永远不会得到断管.那么Nginx代理django时可能会出现问题吗?
UPDATE. I noticed if I request to django server directly I never get Broken pipe. So may the issue occur while Nginx proxy django?
推荐答案Nginx 指令 proxy_intercept_errors off;(默认禁用)正是我需要的
Nginx directive proxy_intercept_errors off; (disabled by default) is what I needed
更多推荐
调试模式下的 Django 管道损坏
发布评论