Skip to content
Myr

Update uwsgi/nginx deployment documentation

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Instead of using the uwsgi_modifier1 30 directive, the uwsgi docs recommend to use the mount / manage-script-name approch which mounts a module + callable to a certain path. This way, SCRIPT_NAME and PATH_INFO are correctly rewritten. See http://uwsgi-docs.readthedocs.org/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and-path-info Fixes #1464

authored by Jonas Gröger · committed by Jonas Gröger · parent 7f38674 · Browse files · 1 file+13 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−9 removed

  • other:+13 added−9 removed

1 file+13 added−9 removed

modified:docs/deploying/uwsgi.rst+13 added-9 removed
27 unmodified lines
28Given a flask application in myapp.py, use the following command:2930.. sourcecode:: text3132 $ uwsgi -s /tmp/uwsgi.sock --module myapp --callable app32 $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app3334Or, if you prefer:3536.. sourcecode:: text3738 $ uwsgi -s /tmp/uwsgi.sock -w myapp:app38 $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app3940The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME`` to41uwsgi, since its smarter about that. It is used together with the ``--mount``42directive which will make requests to ``/yourapplication`` be directed to43``myapp:app``, where ``myapp`` refers to the name of the file of your flask44application (without extension). ``app`` is the callable inside of your45application (usually the line reads ``app = Flask(__name__)``.4647Configuring nginx48-----------------4943A basic flask uWSGI configuration for nginx looks like this::50A basic flask nginx configuration looks like this::5152 location = /yourapplication { rewrite ^ /yourapplication/; }53 location /yourapplication { try_files $uri @yourapplication; }54 location @yourapplication {55 include uwsgi_params;49 uwsgi_param SCRIPT_NAME /yourapplication;50 uwsgi_modifier1 30;51 uwsgi_pass unix:/tmp/uwsgi.sock;56 uwsgi_pass unix:/tmp/yourapplication.sock;57 }5859This configuration binds the application to ``/yourapplication``. If you want55to have it in the URL root it's a bit simpler because you don't have to tell56it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it::60to have it in the URL root its a bit simpler::6162 location / { try_files $uri @yourapplication; }63 location @yourapplication {64 include uwsgi_params;61 uwsgi_pass unix:/tmp/uwsgi.sock;65 uwsgi_pass unix:/tmp/yourapplication.sock;66 }6768.. _nginx: http://nginx.org/69.. _lighttpd: http://www.lighttpd.net/
2 unmodified lines