0

I have a Django application running with a gunicorn ASGI server and an NGINX reverse proxy for serving static content. All are packaged within a docker container.
Now I want to serve this container behind a reverse proxy with a path prefix, e.g. "mydomain.com/djangoapp/". The problem is, that Django doesn't know it's hosted under a subpath, and for example, the Django admin application then always redirects to the root path "/" instead of "/djangoapp/".

I already read that there are several settings that handle this problem.

  1. I tried setting the "FORCE_SCRIPT_NAME" in the Django settings directly to "/djangoapp". It worked for the admin login page, but after clicking the login button it redirected to the wrong root "/".

  2. I tried setting the "SCRIPT_NAME" environment variable of the gunicorn server to "/djangoapp". It did not apply at all.

I'm running now out of ideas on what else to try. Does anybody else have a solution for this problem?

Raju Ahmed
  • 1,282
  • 5
  • 15
  • 24
mrdlink
  • 266
  • 4
  • 15

1 Answers1

0

FORCE_SCRIPT_NAME should work. For the post-login redirect you need to properly set LOGIN_REDIRECT_URL

Ryan Nowakowski
  • 811
  • 7
  • 10