diff --git a/js/index.js b/js/index.js index 10319905..c9ea176c 100644 --- a/js/index.js +++ b/js/index.js @@ -42,10 +42,13 @@ function status(text) { document.getElementById("status").textContent = text; } -// This page is served under the /desktop/, and the websockify websocket is served -// under /desktop-websockify/ with the same base url as /desktop/. We resolve it relatively +// This page is served under the /desktopvnc/, and the websockify websocket is served +// under /desktop/ with the same base url as /desktopvnc/. We resolve it relatively // this way. -let websockifyUrl = new URL("../desktop-websockify/", window.location); +let websockifyUrl = new URL( + window.location.pathname.replace(/vnc\/+$/, "/"), + window.location, +); websockifyUrl.protocol = window.location.protocol === "https:" ? "wss" : "ws"; let retryCount = 0; diff --git a/jupyter_remote_desktop_proxy/server_extension.py b/jupyter_remote_desktop_proxy/server_extension.py index a998f2a7..d15db893 100644 --- a/jupyter_remote_desktop_proxy/server_extension.py +++ b/jupyter_remote_desktop_proxy/server_extension.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from jupyter_server.base.handlers import AuthenticatedFileHandler @@ -15,18 +16,21 @@ def load_jupyter_server_extension(server_app): """ base_url = server_app.web_app.settings["base_url"] - server_app.web_app.add_handlers( - ".*", - [ - # Serve our own static files - ( - url_path_join(base_url, "/desktop/static/(.*)"), - AuthenticatedFileHandler, - {"path": (str(HERE / "static"))}, - ), - # To simplify URL mapping, we make sure that /desktop/ always - # has a trailing slash - (url_path_join(base_url, "/desktop"), AddSlashHandler), - (url_path_join(base_url, "/desktop/"), DesktopHandler), - ], - ) + jupyter_remote_desktop_endpoints = os.getenv('JUPYTER_REMOTE_DESKTOP_ENDPOINTS', '') + endpoints = ['desktop'] + jupyter_remote_desktop_endpoints.split(',') + for endpoint in endpoints: + server_app.web_app.add_handlers( + ".*", + [ + # Serve our own static files + ( + url_path_join(base_url, f"/{endpoint}vnc/static/(.*)"), + AuthenticatedFileHandler, + {"path": (str(HERE / "static"))}, + ), + # To simplify URL mapping, we make sure that /desktop/ always + # has a trailing slash + (url_path_join(base_url, f"/{endpoint}vnc"), AddSlashHandler), + (url_path_join(base_url, f"/{endpoint}vnc/"), DesktopHandler), + ], + ) diff --git a/jupyter_remote_desktop_proxy/setup_websockify.py b/jupyter_remote_desktop_proxy/setup_websockify.py index e9a56a72..ac4f931a 100644 --- a/jupyter_remote_desktop_proxy/setup_websockify.py +++ b/jupyter_remote_desktop_proxy/setup_websockify.py @@ -56,10 +56,10 @@ def setup_websockify(): 'command': ['/bin/sh', '-c', f'cd {os.getcwd()} && {vnc_command}'], 'timeout': 30, 'new_browser_window': True, - # We want the launcher entry to point to /desktop/, not to /desktop-websockify/ - # /desktop/ is the user facing URL, while /desktop-websockify/ now *only* serves + # We want the launcher entry to point to /desktopvnc/, not to /desktop/ + # /desktop/ is the user facing URL, while /desktop/ now *only* serves # websockets. - "launcher_entry": {"title": "Desktop", "path_info": "desktop"}, + "launcher_entry": {"title": "Desktop", "path_info": "desktopvnc"}, "unix_socket": True, "raw_socket_proxy": True, } diff --git a/jupyter_remote_desktop_proxy/templates/index.html b/jupyter_remote_desktop_proxy/templates/index.html index 38b88c09..ce875924 100644 --- a/jupyter_remote_desktop_proxy/templates/index.html +++ b/jupyter_remote_desktop_proxy/templates/index.html @@ -13,13 +13,16 @@ Chrome Frame. --> - +
- +