所有人,
我有一个API,有两个端点是用Flask构建的。我正在使用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;
    }
}

08-07 17:36