[Django] #31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode

16 views
Skip to first unread message

Django

unread,
Nov 20, 2019, 7:38:08 PM11/20/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-----------------------------------------+------------------------
Reporter: thenewguy | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
It would minimize configuration for new projects if ALLOWED_HOSTS +=
['.localhost'] when DEBUG=True

Chrome resolves *.localhost to localhost without modifying any host files
or DNS

Referencing the project this way makes it easy to test subdomains ->
static.localhost, uploads.localhost, www.localhost, etc

--
Ticket URL: <https://code.djangoproject.com/ticket/31010>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 21, 2019, 5:13:12 AM11/21/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------+--------------------------------------
Reporter: thenewguy | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => needsinfo


Comment:

Interesting. Currently we have, in HttpRequest.get_host():

{{{
# Allow variants of localhost if ALLOWED_HOSTS is empty and
DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
}}}

Can I ask you to post to the DevelopersMailingList to canvas opinion?
Assuming no blockers are raised it seems reasonable enough... (Reopen if
accepted there.)

--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:1>

Django

unread,
Nov 21, 2019, 4:41:17 PM11/21/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------+--------------------------------------
Reporter: thenewguy | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by thenewguy):

For reference, the conversation chain has been started:
https://groups.google.com/forum/#!topic/django-developers/xcoAF9Gm_dI

--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:2>

Django

unread,
Nov 22, 2019, 1:40:38 PM11/22/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------+------------------------------------

Reporter: thenewguy | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by thenewguy):

* status: closed => new
* resolution: needsinfo =>
* easy: 0 => 1
* stage: Unreviewed => Accepted


Old description:

> It would minimize configuration for new projects if ALLOWED_HOSTS +=
> ['.localhost'] when DEBUG=True
>
> Chrome resolves *.localhost to localhost without modifying any host files
> or DNS
>
> Referencing the project this way makes it easy to test subdomains ->
> static.localhost, uploads.localhost, www.localhost, etc

New description:

It would minimize configuration for new projects if ALLOWED_HOSTS +=
['.localhost'] when DEBUG=True

Chrome resolves *.localhost to localhost without modifying any host files
or DNS

Referencing the project this way makes it easy to test subdomains ->
static.localhost, uploads.localhost, www.localhost, etc

---
Updated
---

Conversation on developer mailing list resulted in decision to reopen and
accept ticket. The conversation turned up that this behavior is spec
compliant per https://tools.ietf.org/html/rfc6761#section-6.3

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:3>

Django

unread,
Nov 23, 2019, 9:22:00 PM11/23/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------+-------------------------------------
Reporter: thenewguy | Owner: thenewguy
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by thenewguy):

* owner: nobody => thenewguy
* status: new => assigned
* has_patch: 0 => 1


Comment:

PR submitted https://github.com/django/django/pull/12132

--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:4>

Django

unread,
Nov 23, 2019, 9:22:38 PM11/23/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------------+-------------------------------------

Reporter: thenewguy | Owner: thenewguy
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by thenewguy):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:5>

Django

unread,
Nov 24, 2019, 9:42:17 AM11/24/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------+-------------------------------------
Reporter: thenewguy | Owner: thenewguy
Type: Uncategorized | Status: assigned
Component: Uncategorized | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
* stage: Ready for checkin => Accepted


Comment:

Hey there, thanks for your PR! Please don't mark your own patch ''Ready
for Checking'', someone else has to review it and mark it accordingly. I
left come comments for improvements on the PR.

--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:6>

Django

unread,
Nov 29, 2019, 5:30:38 PM11/29/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------+-------------------------------------
Reporter: thenewguy | Owner: thenewguy
Type: New feature | Status: assigned
Component: Uncategorized | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by felixxm):

* type: Uncategorized => New feature


--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:7>

Django

unread,
Dec 5, 2019, 4:04:56 AM12/5/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------------+-------------------------------------

Reporter: thenewguy | Owner: thenewguy
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* version: 2.2 => master
* component: Uncategorized => HTTP handling
* needs_tests: 1 => 0


* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:8>

Django

unread,
Dec 5, 2019, 4:05:58 AM12/5/19
to django-...@googlegroups.com
#31010: Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: thenewguy
Type: New feature | Status: closed

Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"adb96617897690b3a01e39e8297ae7d67825d2bc" adb9661]:
{{{
#!CommitTicketReference repository=""
revision="adb96617897690b3a01e39e8297ae7d67825d2bc"
Fixed #31010 -- Allowed subdomains of localhost in the Host header by
default when DEBUG=True.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31010#comment:9>

Reply all
Reply to author
Forward
0 new messages