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 /foo:


If you've not done so already, edit your site to assign myapp to the URI path /foo.


Locate your application's uwsgi.ini file. By default this file is created in the root of your application directory like /home/username/apps/myapp/uwsgi.ini.


Open the uwsgi.ini file in your preferred editor.


Change the wsgi-file configuration line from this:

wsgi-file = /home/shelluser/apps/myapp/myproject/myproject/

... to this ...

mount = /foo=/home/shelluser/apps/myapp/myproject/myproject/

Be sure that the /foo in the mount line matches the URI path that you've assigned to the site in the control panel.


Add the following line to the end of the uwsgi.ini file:

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.