Fix 403 error when listening on 127.0.0.1:80.

This commit is contained in:
JeremyRand 2018-06-02 10:24:00 +00:00
parent efcb1715ee
commit f7f6b15ef1
No known key found for this signature in database
GPG Key ID: B3F2D165786D6570
1 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,14 @@ class UiServer:
self.learn_allowed_host = False
elif config.ui_ip == "127.0.0.1":
self.allowed_hosts = set(["zero", "localhost:%s" % config.ui_port, "127.0.0.1:%s" % config.ui_port])
# "URI producers and normalizers should omit the port component and
# its ':' delimiter if port is empty or if its value would be the
# same as that of the scheme's default."
# Source: https://tools.ietf.org/html/rfc3986#section-3.2.3
# As a result, we need to support portless hosts if port 80 is in
# use.
if config.ui_port == 80:
self.allowed_hosts.update(["localhost", "127.0.0.1"])
self.learn_allowed_host = False
else:
self.allowed_hosts = set([])