From 76afec8adb8e30b6102854ebf79bbe1c0726c27c Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sat, 12 Oct 2019 12:44:02 +1300 Subject: [PATCH] Update app.bind_url and proxy.public_url when (external) SSL is enabled --- jupyterhub/app.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jupyterhub/app.py b/jupyterhub/app.py index 0cf649bf..dda4c127 100644 --- a/jupyterhub/app.py +++ b/jupyterhub/app.py @@ -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.