Send to Kindle
home » snippets » uwsgi


Multiple wsgi apps with nginx and uwsgi

Typically, we specify the module / --module param to uwsgi startup naming the wsgi app to use. Nginx can pass this param to uwsgi allowing the choice of app to be specified that way.  So here's on way to do it.

Nginx config

include /.../customize/nginx/uwsgi_params; 
uwsgi_param SCRIPT_NAME   $app;        
uwsgi_param UWSGI_MODULE   $app;
# Also see http://stackoverflow.com/a/8618323/157154
uwsgi_modifier1   30;   #properly sets PATH_INFO variable
# The default is "application".
# uwsgi_param UWSGI_CALLABLE  default_uwsgi_app;
# Specifies the virtual env to use.
# uwsgi_param UWSGI_PYHOME   $document_root;
# uwsgi_param UWSGI_CHDIR   $document_root;

upstream uwsgi_workers_ckck {
    server unix:/tmp/uwsgi.sock;

server {
    server_name   _  default_server;

    location ~ /(\w+) {
        set   $app   $1;
        uwsgi_pass   uwsgi_workers_ckck;

Uwsgi config

uwsgi --socket /tmp/uwsgi.sock --master --vhost --pp $PYTHONPATH