所有,
我有一个使用Flask构建的具有两个端点的API。我正在使用nginx / uwsgi组合来提供服务,每当我向端点之一发送GET请求时,我都会收到一个奇怪的错误。另一个端点工作正常。
这是来自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'
并且,这是来自get请求的nginx错误日志的输出
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"
对于这个问题的含糊之处,我深表歉意。我已经在相同的硬件,相同的库上多次设置了该服务器,并且之前没有任何问题。错误令人困惑,我不确定从哪里开始寻找。
提前致谢!
愚蠢的错误。我的nginx配置出现错误。它指向一个不存在的套接字。
server { listen 80; server_name scholarly; # crowdscholar endpoint location /crowdscholar { uwsgi_pass unix:///tmp/crowdscholar.sock; include uwsgi_params; # strip path before handing it to app uwsgi_param SCRIPT_NAME /crowdscholar; uwsgi_modifier1 30; } # citelet endpoint location /citelet { uwsgi_pass unix:///tmp/citelet.sock; include uwsgi_params; # strip path before handing it to app uwsgi_param SCRIPT_NAME /citelet; uwsgi_modifier1 30; } }