Saturday, October 11, 2014

Nginx + fastcgi/wsgi

Python web application normally should use wsgi as interface, but nginx only support fascgi, scgi,uwsgi and no wsgi support.

flup is python library which could convert your wsgi application into fastcgi server. Since it is a library, you don't need to setup other extra standalone application. flup could hep to set up fastcgi through Unix socket domain or TCP port. It is also support scgi. webpy could use flup directly.
app = web.application(urls,locals())
if __name__ == '__main__':
#web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr) for unix socket domain
#web.wsgi.runwsgi = lambda func, addr="/tmp/test.sock": web.wsgi.runfcgi(func, addr) for Tcp port
#web.wsgi.runwsgi = lambda func, addr=("localhost",7070): web.wsgi.runfcgi(func, addr) used with spawn-fcgi
different addr could be config as different fastcgi behavior. just simply refer to web.wsgi.runwsgi.

uwsgi needs to be isntalled if you want use wsgi + nginx. I don't see webpy could support uwsgi protocal directly.

Post a Comment