Mastering Nginx

(Ron) #1
Chapter 6

[ 155 ]

see http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html


and http://projects.unbit.it/uwsgi/wiki/Example


upstream emperor {


server 127.0.0.1:3017;
}


server {


the document root is set with a variable so that multiple


sites


may be served - note that all static application files are


expected to be found under a subdirectory "static" and all


user


uploaded files under a subdirectory "media"


see https://docs.djangoproject.com/en/dev/howto/static-


files/
root /home/www/sites/$host;


location / {


CSS files are found under the "styles" subdirectory


location ~* ^.+.$ {


root /home/www/sites/$host/static/styles;
expires 30d;
}


any paths not found under the document root get passed


to


the Django running under uWSGI


try_files $uri @django;
}


location @django {


$document_root needs to point to the application code


root /home/www/apps/$host;


the uwsgi_params file from the nginx distribution


include uwsgi_params;


referencing the upstream we defined earlier, a uWSGI


server


running in Emperor mode with FastRouter

http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html - Mastering Nginx - free download pdf - issuhub">
Free download pdf