From 7767bc6740914a5ff96bc397a62229c696b0e95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 27 May 2017 19:14:48 +0200 Subject: [PATCH] use django facilities to get hostname from request (#16525) This is required as SERVER_NAME may not be used in some uwsgi configuration, and HTTP_HOST should be used instead. | Nginx maps the $server_name variable to the first server_name you define. | In your case you have two solutions: read HTTP_HOST instead of SERVER_NAME | in your app or set SERVER_NAME to $http_host in uwsgi_params -- http://lists.unbit.it/pipermail/uwsgi/2010-August/000571.html The HttpRequest.get_host method handles those cases and more. --- mellon/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mellon/middleware.py b/mellon/middleware.py index 57bf1b5..2c1d3fd 100644 --- a/mellon/middleware.py +++ b/mellon/middleware.py @@ -35,7 +35,7 @@ class PassiveAuthenticationMiddleware(object): # get the common domain or guess common_domain = app_settings.OPENED_SESSION_COOKIE_DOMAIN if not common_domain: - common_domain = request.META['SERVER_NAME'].split('.', 1)[1] + common_domain = request.get_host().split('.', 1)[1] assert '.' in common_domain # if domain is xxx.com explode ! params = { 'next': request.build_absolute_uri(),