Welcome! Log In Create A New Profile

Advanced

nginx + uwsgi + cherrypy application

Posted by appdev1 
nginx + uwsgi + cherrypy application
September 14, 2011 02:22PM
Hi, getting 502 error, "upstream prematurely closed connection while reading response header from upstream" with the below setup.
Appreciate any troubleshooting suggestions as am pretty new to all of this.
thanks

Note:
if take nginx out of the picture and just serve up the app through uwsgi on localhost:9090, the page resolves.


################################################################################
# setup
################################################################################

#nginx.conf snippet
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}

#start uwsgi with this command: uwsgi --ini /etc/uwsgi/config.ini
#uwsgi config.ini
socket=/tmp/uwsgi.sock
wsgi-file=/var/www/hi.py
processes=1
master=true
harakiri=5
daemonize=/var/log/uwsgi.log
uid=uwsgi
gid=uwsgi
chmod-socket=666
pidfile=/var/run/uwsgi.pid


#hi.py
import cherrypy

class HelloWorld(object):
@cherrypy.expose
def index(self):
return "Hello World!"

application = cherrypy.Application(HelloWorld(), '/')

################################################################################
# log files
################################################################################
#uwsgi
http status must be a string !
[pid: 2071|app: 0|req: 5/5] 127.0.0.1 () {38 vars in 640 bytes} [Wed Sep 14 12:11:59 2011] GET / => generated 14 bytes in 1 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 0)
127.0.0.1 - - [14/Sep/2011:12:11:59] "GET /nginx-logo.png HTTP/1.1" 404 1414 "http://localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1"
http status must be a string !
[pid: 2071|app: 0|req: 6/6] 127.0.0.1 () {40 vars in 641 bytes} [Wed Sep 14 12:11:59 2011] GET /nginx-logo.png => generated 1414 bytes in 5 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 0)
127.0.0.1 - - [14/Sep/2011:12:11:59] "GET /poweredby.png HTTP/1.1" 404 1412 "http://localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1"
http status must be a string !
[pid: 2071|app: 0|req: 7/7] 127.0.0.1 () {40 vars in 639 bytes} [Wed Sep 14 12:11:59 2011] GET /poweredby.png => generated 1412 bytes in 8 msecs (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 0)

#ngnix access
127.0.0.1 - - [14/Sep/2011:12:11:59 -0500] "GET / HTTP/1.1" 502 3695 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1" "-"
127.0.0.1 - - [14/Sep/2011:12:11:59 -0500] "GET /nginx-logo.png HTTP/1.1" 200 1022 "http://localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1" "-"
127.0.0.1 - - [14/Sep/2011:12:11:59 -0500] "GET /poweredby.png HTTP/1.1" 200 1020 "http://localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1" "-"

#nginx error
2011/09/14 12:11:59 [error] 2007#0: *112 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "localhost"
2011/09/14 12:11:59 [error] 2007#0: *114 upstream sent neither valid HTTP/1.0 header nor "Status" header line while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /nginx-logo.png HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "localhost", referrer: "http://localhost/"
2011/09/14 12:11:59 [error] 2007#0: *115 upstream sent neither valid HTTP/1.0 header nor "Status" header line while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /poweredby.png HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "localhost", referrer: "http://localhost/"
Re: nginx + uwsgi + cherrypy application
September 20, 2011 11:02AM
Looks like a cherrypy bug.
http://www.cherrypy.org/ticket/1087
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 150
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready