@@ -666,6 +666,19 @@ def _valdate_ip(self, proposal):
666
666
value = u''
667
667
return value
668
668
669
+ custom_display_url = Unicode (u'' , config = True ,
670
+ help = _ ("""Override URL shown to users.
671
+
672
+ Replace actual URL, including protocol, address, port and base URL,
673
+ with the given value when displaying URL to the users. Do not change
674
+ the actual connection URL. If authentication token is enabled, the
675
+ token is added to the custom URL automatically.
676
+
677
+ This option is intended to be used when the URL to display to the user
678
+ cannot be determined reliably by the Jupyter notebook server (proxified
679
+ or containerized setups for example).""" )
680
+ )
681
+
669
682
port = Integer (8888 , config = True ,
670
683
help = _ ("The port the notebook server will listen on." )
671
684
)
@@ -1339,11 +1352,16 @@ def init_webapp(self):
1339
1352
1340
1353
@property
1341
1354
def display_url (self ):
1342
- if self .ip in ('' , '0.0.0.0' ):
1343
- ip = socket .gethostname ()
1355
+ if self .custom_display_url :
1356
+ url = self .custom_display_url
1357
+ if not url .endswith ('/' ):
1358
+ url += '/'
1344
1359
else :
1345
- ip = self .ip
1346
- url = self ._url (ip )
1360
+ if self .ip in ('' , '0.0.0.0' ):
1361
+ ip = socket .gethostname ()
1362
+ else :
1363
+ ip = self .ip
1364
+ url = self ._url (ip )
1347
1365
if self .token :
1348
1366
# Don't log full token if it came from config
1349
1367
token = self .token if self ._token_generated else '...'
0 commit comments