1

I have a Django project running on Apache2 with mod_wsgi in a VM - https://systems3.slt.local/

Accessing the VM directly, via https://systems3.slt.local/ works perfectly. However, I need it to work behind an NGINX reverse proxy, and I'm having problems with login redirection.

My proxy is configured like this:

location /systems3 {
                 proxy_set_header Host $host;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_set_header X-Forwarded-Proto $scheme;
                 proxy_redirect off;
                 proxy_pass https://systems3.slt.local/;
         }

When I try to access the project through the proxy, /systems3, Django checks that there is no user logged in, and then redirects to /accounts/login. The correct would be to redirect to /systems3/accounts/login/. Even if I try to directly access this address, I am redirected to /accounts/login.

It seems that some configuration is missing so that the address /systems3 is the root of the project, it shouldn't be redirecting me outside of systems3.

It's also giving problem with my static folder, it also looks for the folder at /static, ignoring that it was supposed to look inside systems3.

Ivan Starostin
  • 8,798
  • 5
  • 21
  • 39
Neto
  • 11
  • 1
  • Does this answer your question? [Django in subdirectory - admin site is not working](https://stackoverflow.com/questions/44987110/django-in-subdirectory-admin-site-is-not-working) – Ivan Starostin Jun 28 '22 at 06:01
  • It partially worked. In addition to these settings, I needed to put LOGIN_URL = '/systems3/accounts/login' and LOGOUT_URL = '/systems3/accounts/logout' and STATIC_FILES_ROOT, STATIC_FILES_URLS, I needed to change to STATIC_ROOT and STATIC_URL. Tks. – Neto Jun 28 '22 at 17:15

0 Answers0