From 8b9cb6caa71c2db1a9c2ebd66f77ffe8b6306623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Gr=C3=B6ger?= Date: Sat, 22 Aug 2015 00:56:54 +0200 Subject: [PATCH] Update uwsgi/nginx deployment documentation 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 --- docs/deploying/uwsgi.rst | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/deploying/uwsgi.rst b/docs/deploying/uwsgi.rst index f181d731..8ab985b9 100644 --- a/docs/deploying/uwsgi.rst +++ b/docs/deploying/uwsgi.rst @@ -29,36 +29,40 @@ Given a flask application in myapp.py, use the following command: .. sourcecode:: text - $ uwsgi -s /tmp/uwsgi.sock --module myapp --callable app + $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app Or, if you prefer: .. sourcecode:: text - $ uwsgi -s /tmp/uwsgi.sock -w myapp:app + $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app + +The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME`` to +uwsgi, since its smarter about that. It is used together with the ``--mount`` +directive which will make requests to ``/yourapplication`` be directed to +``myapp:app``, where ``myapp`` refers to the name of the file of your flask +application (without extension). ``app`` is the callable inside of your +application (usually the line reads ``app = Flask(__name__)``. Configuring nginx ----------------- -A basic flask uWSGI configuration for nginx looks like this:: +A basic flask nginx configuration looks like this:: location = /yourapplication { rewrite ^ /yourapplication/; } location /yourapplication { try_files $uri @yourapplication; } location @yourapplication { include uwsgi_params; - uwsgi_param SCRIPT_NAME /yourapplication; - uwsgi_modifier1 30; - uwsgi_pass unix:/tmp/uwsgi.sock; + uwsgi_pass unix:/tmp/yourapplication.sock; } This configuration binds the application to ``/yourapplication``. If you want -to have it in the URL root it's a bit simpler because you don't have to tell -it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it:: +to have it in the URL root its a bit simpler:: location / { try_files $uri @yourapplication; } location @yourapplication { include uwsgi_params; - uwsgi_pass unix:/tmp/uwsgi.sock; + uwsgi_pass unix:/tmp/yourapplication.sock; } .. _nginx: http://nginx.org/