Question

I have a pylons app that I'm trying to run behind NGINX with uWSGI. The app makes a GET request using httplib. When testing under paster, the app receives the data from the GET request normally, but after setting it up behind uWSGI, I get the following error in my nginx log:

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:"

And this in the uwsgi log:

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)

I thought it might be a timeout problem, but I've set the following for uwsgi:

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

I'm sure I'm missing something with the uWSGI configuration. Can anyone point me in the right direction?

Was it helpful?

Solution

Your app (pylons) is expecting the SCRIPT_NAME variable:

environ['SCRIPT_NAME'] += '/'

KeyError: 'SCRIPT_NAME'

just tell nginx to pass it to uWSGI:

uwsgi_param SCRIPT_NAME "";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top