Merge pull request #1444 from JeremyRand/port-80

Fix 403 error when listening on 127.0.0.1:80.
This commit is contained in:
ZeroNet 2018-06-02 17:50:07 +02:00 committed by GitHub
commit 11c66f6ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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([])