My proxy (nginx public port 80) to django (gunicorn wsgi localhost port 8000) strips off the path to the application "/app" so requests for http://server/app/hello
appears to django as /hello
and requests for http://server/app/admin
appears to django as /admin
.
The problem is that the admin site generates output with absolute URLs such as <form action="/admin/"...
in the login screen. So the user sees the admin login screen but it posts to http://server/admin
which doesn't exist. (I kind of hoped it would use relative URLs and work at any location.)
What is the simplest way to get the admin pages to universally prepend "/app" like form action="/app/admin/"
to all URLs it generates in page output? I am hoping for something built into Django like a simple define, and not having to create special filters then rewrite templates to use them, but I can't seem to find it.
See documentation for FORCE_SCRIPT_NAME:
https://docs.djangoproject.com/en/dev/ref/settings/#force-script-name
Set that to be '/app' instead of default of None.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With