Serving a Django app on a sub-path
The default uWSGI configuration created by our Django application installer works for Django applications running at the root of your domain - that is, the Django app is attached to your site route using
/ as the URI path.
If you need to run your application on a URI path below the root (aka a sub-path) then some minor changes to your application's uWSGI configuration are needed.
The following steps show how to serve a Django app named
myapp (owned by
shelluser) on a URI path
If you've not done so already, edit your site to assign
myappto the URI path
Locate your application's
uwsgi.inifile. By default this file is created in the root of your application directory like
uwsgi.inifile in your preferred editor.
wsgi-fileconfiguration line from this:
wsgi-file = /home/shelluser/apps/myapp/myproject/myproject/wsgi.py
... to this ...
mount = /foo=/home/shelluser/apps/myapp/myproject/myproject/wsgi.py
Be sure that the
mountline matches the URI path that you've assigned to the site in the control panel.
Add the following line to the end of the
manage-script-name = True
Save the file and exit your editor.
Restart the application:
After you've restarted the application it should then be available on
/foo or whatever URI path you assigned to it.
Finally, please note that with these instructions it is not necessary to use
FORCE_SCRIPT_NAME in your Django project settings.