0

我有一个 pylons 应用程序,我正在尝试使用 uWSGI 在 NGINX 后面运行。该应用程序使用 httplib 发出 GET 请求。在 paste 下测试时,应用程序正常接收来自 GET 请求的数据,但是在 uWSGI 后面设置后,我的 nginx 日志中出现以下错误:

2013/09/20 21:52:07 [error] 3920#0: *10 upstream prematurely closed connection while reading response header from upstream, client: ***, server: ***.com, request: "GET /getElevation?X_Value=-105.61019897460938&Y_Value=40.24959460394122 HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.maps.sock:"

这在 uwsgi 日志中:

Traceback (most recent call last):
  File "/root/.virtualenvs/maps/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/cascade.py", line 117, in __call__
    v = app(environ_copy, repl_start_response)
  File "/root/.virtualenvs/maps/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/urlparser.py", line 446, in __call__
    filename = request.path_info_pop(environ)
  File "/root/.virtualenvs/maps/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/request.py", line 309, in path_info_pop
    environ['SCRIPT_NAME'] += '/'
KeyError: 'SCRIPT_NAME'
[pid: 3897|app: 0|req: 1/4] **** () {44 vars in 1228 bytes} [Fri Sep 20 21:52:07 2013] GET /getElevation?X_Value=-105.61097145080566&Y_Value=40.24500880734505 => generated 0 bytes in 1 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
...The work of process 3897 is done. Seeya!
worker 2 killed successfully (pid: 3897)
Respawned uWSGI worker 2 (new pid: 3925)

我认为这可能是超时问题,但我为 uwsgi 设置了以下内容:

socket-timeout = 15
http-timeout = 15
harakiri = 60

我确定我在 uWSGI 配置中遗漏了一些东西。谁能指出我正确的方向?

4

1 回答 1

0

您的应用程序 (pylons) 需要 SCRIPT_NAME 变量:

环境['SCRIPT_NAME'] += '/'

KeyError:'SCRIPT_NAME'

只需告诉 nginx 将其传递给 uWSGI:

uwsgi_param SCRIPT_NAME "";
于 2013-09-21T03:36:15.253 回答