1👍
Use request.get_host()
:
Returns the originating host of the request using information from the
HTTP_X_FORWARDED_HOST (if USE_X_FORWARDED_HOST is enabled) and
HTTP_HOST headers, in that order.
1👍
The get_host()
method fails when the host is behind multiple proxies. One solution is to use middleware to rewrite the proxy headers, as in the following example https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.get_host
Source:stackexchange.com