Skip to content

Commit

Permalink
allow different internal and public hub_url
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Nov 2, 2019
1 parent 76b9d19 commit 47b4f11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion binderhub/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,15 @@ def _default_hub_token(self):
""",
config=True,
)
@validate('hub_url')

hub_url_public = Unicode(
help="""
The public base URL of the JupyterHub instance where users will run if different from hub_url
""",
config=True,
)

@validate('hub_url', 'hub_url_public')
def _add_slash(self, proposal):
"""trait validator to ensure hub_url ends with a trailing slash"""
if proposal.value is not None and not proposal.value.endswith('/'):
Expand Down Expand Up @@ -549,6 +557,7 @@ def initialize(self, *args, **kwargs):
self.launcher = Launcher(
parent=self,
hub_url=self.hub_url,
hub_url_public=self.hub_url_public,
hub_api_token=self.hub_api_token,
create_user=not self.auth_enabled,
)
Expand Down
3 changes: 2 additions & 1 deletion binderhub/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Launcher(LoggingConfigurable):

hub_api_token = Unicode(help="The API token for the Hub")
hub_url = Unicode(help="The URL of the Hub")
hub_url_public = Unicode(help="The public URL of the Hub if different")
create_user = Bool(True, help="Create a new Hub user")
retries = Integer(
4,
Expand Down Expand Up @@ -196,5 +197,5 @@ async def launch(self, image, username, server_name='', repo_url=''):
format(_server_name, username, e, body))
raise web.HTTPError(500, "Failed to launch image %s" % image)

data['url'] = self.hub_url + 'user/%s/%s' % (username, server_name)
data['url'] = (self.hub_url_public or self.hub_url) + 'user/%s/%s' % (username, server_name)
return data

0 comments on commit 47b4f11

Please sign in to comment.