Skip to content

Commit

Permalink
Use hub_url_local for internal BinderHub➡️ JupyterHub traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Oct 30, 2020
1 parent a23550c commit 3d10c9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion binderhub/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def initialize(self, *args, **kwargs):
tornado.web.StaticFileHandler,
{'path': os.path.join(self.tornado_settings['static_path'], 'images')}),
(r'/about', AboutHandler),
(r'/health', HealthHandler, {'hub_url': self.hub_url}),
(r'/health', HealthHandler, {'hub_url': self.hub_url_local}),
(r'/', MainHandler),
(r'.*', Custom404),
]
Expand Down
7 changes: 5 additions & 2 deletions binderhub/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tornado import web, gen
from tornado.httpclient import AsyncHTTPClient, HTTPRequest, HTTPError
from traitlets.config import LoggingConfigurable
from traitlets import Integer, Unicode, Bool
from traitlets import Integer, Unicode, Bool, default
from jupyterhub.traitlets import Callable
from jupyterhub.utils import maybe_future

Expand All @@ -35,6 +35,9 @@ 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_local = Unicode(help="The internal URL of the Hub if different")
@default('hub_url_local')
def _default_hub_url_local(self):
return self.hub_url
create_user = Bool(True, help="Create a new Hub user")
allow_named_servers = Bool(
os.getenv('JUPYTERHUB_ALLOW_NAMED_SERVERS', "false") == "true",
Expand Down Expand Up @@ -82,7 +85,7 @@ async def api_request(self, url, *args, **kwargs):
"""Make an API request to JupyterHub"""
headers = kwargs.setdefault('headers', {})
headers.update({'Authorization': 'token %s' % self.hub_api_token})
hub_api_url = os.getenv('JUPYTERHUB_API_URL', '') or self.hub_url + 'hub/api/'
hub_api_url = os.getenv('JUPYTERHUB_API_URL', '') or self.hub_url_local + 'hub/api/'
request_url = hub_api_url + url
req = HTTPRequest(request_url, *args, **kwargs)
retry_delay = self.retry_delay
Expand Down

0 comments on commit 3d10c9f

Please sign in to comment.