﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31354	HttpRequest.get_host() doesn't include the port from META['HTTP_X_FORWARDED_PORT'].	dgcgh	Calvin Vu	"request.get_port() should include the port of the authority if it is not 80 for http or 443 for https. Currently this does not happen when HTTP_X_FORWARDED_HOST is present in request.META.

This causes issues for e.g. request.build_absolute_uri() if the django app is running behind a reverse proxy on a non-standard port.

Example would be: nginx is listening on port 8443 and forwarding to a django server listening on port 8001:
{{{
server {
    listen      8443 ssl;
    server_name         localhost.example.com

   location / {
        proxy_pass  http://localhost:8001;
        # include     /etc/nginx/uwsgi_params;
        proxy_cache_bypass  $http_upgrade;

        proxy_set_header Upgrade           $http_upgrade;
        proxy_set_header Connection        ""upgrade"";
        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_set_header X-Forwarded-Host  $host;
        proxy_set_header X-Forwarded-Port  $server_port;
    }
}
}}}

In this case URIs built with request.build_absolute_uri() in a django app will exclude the port, i.e.:
{{{request.build_django_uri(""/"") == ""https://localhost.example.com/""}}}
where it should return ""https://localhost.example.com:8443/""
"	Bug	assigned	HTTP handling	dev	Normal		request get_host build_absolute_uri	Ülgen Sarıkavak Calvin Vu	Accepted	1	0	0	1	0	0
