[Django]-Hosting a django project behind proxypass

1👍

I did these two things and it worked.

  1. Whenever you add a ProxyPass, you should add ProxyPassReverse

  2. SITE_ID should be set to the domain where you want to point this django project.

3👍

This is happening because the admin redirects to IP it thinks it has. It gets in in the HTTP request’s header.

However, the fix is very easy. Assuming you proxy server implements the X-Forwarded-For standard, it could be easily fixed.

in your settings.py, simply set:

USE_X_FORWARDED_HOST = True

and restart your Django.

If that doesn’t work, you can try to see if your proxy sets a different kind of header, and write a middleware that does the same thing. It’s the first example on Django’s documentation chapter on middleware

Leave a comment