【发布时间】:2013-12-26 20:26:33
【问题描述】:
全部,
我有一个使用 Flask 构建的带有两个端点的 API。我正在使用 nginx/uwsgi 组合进行服务,每当我向其中一个端点发送 GET 请求时,我都会收到一个奇怪的错误。另一个端点工作得很好。
这是我的 uwsgi 日志从获取请求中得到的输出
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1646, in request_context
return RequestContext(self, environ)
File "/usr/local/lib/python2.7/dist-packages/flask/ctx.py", line 166, in __init__
self.url_adapter = app.create_url_adapter(self.request)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in create_url_adapter
server_name=self.config['SERVER_NAME'])
File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1196, in bind_to_environ
environ['REQUEST_METHOD'], environ.get('PATH_INFO'),
KeyError: 'REQUEST_METHOD'
还有,这里是 nginx 错误日志中的一个 get 请求的输出
2013/12/26 15:22:16 [error] 833#0: *9 upstream prematurely closed connection while reading response header from upstream,
client: 71.71.53.31, server: scholarly,
request: "GET /citelet/ HTTP/1.1",
upstream: "uwsgi://unix:///tmp/citelet.sock:",
host: "162.243.219.38"
对于这个问题含糊不清,我深表歉意。我已经在相同的硬件上使用相同的库多次设置此服务器,并且之前没有任何问题。该错误令人困惑,我不确定从哪里开始查找。
提前致谢!
【问题讨论】:
-
你能给你看看 uwsgi 应用程序的 nginx.conf 部分吗?您的 python 应用程序代码也会有所帮助。我遇到了这个,但你的其他端点工作没有意义......en.it-usenet.org/thread/17304/5165/#post5163
-
@AndrewKloos 这是一个愚蠢的错误,几乎总是如此。我的 nginx 配置中有一个字母类型。我将在答案中发布配置。不过感谢我们的回复!