Update app.bind_url and proxy.public_url when (external) SSL is enabled

This commit is contained in:
Bruno P. Kinoshita
2019-10-12 12:44:02 +13:00
committed by Bruno P. Kinoshita
parent 06da90ac76
commit 76afec8adb

View File

@@ -576,6 +576,22 @@ class JupyterHub(Application):
""",
).tag(config=True)
@validate('bind_url')
def _validate_bind_url(self, proposal):
"""ensure protocol field of bind_url matches ssl"""
v = proposal['value']
proto, sep, rest = v.partition('://')
if self.ssl_cert and proto != 'https':
return 'https' + sep + rest
elif proto != 'http' and not self.ssl_cert:
return 'http' + sep + rest
return v
@default('bind_url')
def _bind_url_default(self):
proto = 'https' if self.ssl_cert else 'http'
return proto + '://:8000'
subdomain_host = Unicode(
'',
help="""Run single-user servers on subdomains of this host.