Since v1.5, Django cares about the requested Host (or
X-Forwarded-Host) [1], so we need to pass that information through.
With this Nginx config, you can set USE_X_FORWARDED_HOST [2] and parse
the appropriate hostname instead of your Docker container's IP.
[1]: https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
[2]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-USE_X_FORWARDED_HOST
location / {
proxy_pass ${URL};
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Host $server_name;
}
}