Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to override host in displayed url #3668

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,19 @@ def _valdate_ip(self, proposal):
value = u''
return value

custom_display_url = Unicode(u'', config=True,
help=_("""Override URL shown to users.

Replace actual URL, including protocol, address, port and base URL,
with the given value when displaying URL to the users. Do not change
the actual connection URL. If authentication token is enabled, the
token is added to the custom URL automatically.

This option is intended to be used when the URL to display to the user
cannot be determined reliably by the Jupyter notebook server (proxified
or containerized setups for example).""")
)

port = Integer(8888, config=True,
help=_("The port the notebook server will listen on.")
)
Expand Down Expand Up @@ -1339,11 +1352,16 @@ def init_webapp(self):

@property
def display_url(self):
if self.ip in ('', '0.0.0.0'):
ip = socket.gethostname()
if self.custom_display_url:
url = self.custom_display_url
if not url.endswith('/'):
url += '/'
else:
ip = self.ip
url = self._url(ip)
if self.ip in ('', '0.0.0.0'):
ip = socket.gethostname()
else:
ip = self.ip
url = self._url(ip)
if self.token:
# Don't log full token if it came from config
token = self.token if self._token_generated else '...'
Expand Down