How to run Django on a subpath

23. June 2019 AWS 0

Today, we were trying to run the Django application on a subpath say /backend/ . We were able to run it but some url redirection from the application were still pointing it to the / url instead of /backend/

Let me share the configuration a high level, please comment if you need any clarrification.

My Django project was running with gunicorn on the url

Below is the configuration on my Apache, and yes the application should be on h

SSLProxyEngine on
ProxyPreserveHost On

###########proxy settings###
RequestHeader set "Host" ""
RequestHeader set X-SCRIPT-NAME '/backend/'
ProxyErrorOverride Off

With the above configuration the application will still forward any redirection from the /backend/ , ie say /backend/admin/ to /admin . So we need to add force /backend from the on the Django Code.

So, simply add these lines to your


echo hello

Leave a Reply

Your email address will not be published. Required fields are marked *