﻿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
26037	Document precedence of USE_X_FORWARDED_HOST and USE_X_FORWARDED_PORT settings	Benoît Bryon	nobody	"Situation is Django running behind a reverse proxy such as:

* Django settings declare `USE_X_FORWARDED_HOST = True` and `USE_X_FORWARDED_PORT = True`
* reverse proxy passes headers `X-Forwarded-Host` and `X-Forwarded-Port`. Say host ""example.com"" and port ""8080"" for example.

I was expecting `request.get_absolute_uri()` to use both forwarded host and port.
Or more precisely, I was expecting `request.get_host()` to return ""example.com:8080"" with the example above.

But I get ""example.com"" only, without mention of the forwarded port.

As of Django version 1.9, it seems that, given `settings.USE_X_FORWARDED_HOST` is True, then `request.get_host()` takes only `X-Forwarded-Host` into account and ignores `X-Forwarded-Port`.
I guess issue comes from `HttpRequest._raw_host()` which doesn't use `HttpRequest.get_port()` in the case `settings.USE_X_FORWARDED_HOST` is True.

References:

* `HttpRequest.get_host()`: https://github.com/django/django/blob/b0c56b895fd2694d7f5d4595bdbbc41916607f45/django/http/request.py#L72-L89
* `HttpRequest.get_port()`: https://github.com/django/django/blob/b0c56b895fd2694d7f5d4595bdbbc41916607f45/django/http/request.py#L110-L116
* `settings.USE_X_FORWARDED_PORT` was introduced by https://code.djangoproject.com/ticket/25211"	Cleanup/optimization	closed	Documentation	1.9	Normal	fixed		Matt Robenolt	Ready for checkin	1	0	0	0	0	0
