Connect to external JupyterLab server

Hi all,

I have a JupyterLab apps working well in our OOD v1.8 platform.
Now I want to use this OOD platform to config and access a remote JupyterLab server running outside of the OOD cluster. So I cloned the JupyterLab apps and replace the “jupyter lab” command in “script.sh” with a batch of commands. These commands send config parameters to the remote host to start the JupyterLab server and then conduct the ssh port forwarding to connect to the remote JupyterLab server from the OOD node. However, it returns the “Failed to connect” to the OOD node/port error message after clicking “Connect to Jupyter” button from the OOD portal.

Here is the view.html.erb file:

<form action="/node/<%= host %>/<%= port %>/login" method="post" target="_blank">
  <input type="hidden" name="password" value="<%= password %>">
  <button class="btn btn-primary" type="submit">
    <i class="fa fa-eye"></i> Connect to Jupyter
  </button>
</form>

Looks like OOD reverse proxy can not connect to the forwarded port of a OOD node. Is there a way to access the external JupyterLab server via the OOD portal? Thanks.

Hi Metyr. I have a couple requests please.
1). Can you please post any logs that may have been generated.
2). Can you please post the updated script.sh? If there is information that you do not want made public, please remove that information from the post. If we need that info, we’ll reach out to you.

Hi gbyrket,

Many thanks for your reply.

The “script.sh” is pretty simple as below

#!/usr/bin/env bash
echo "running jupyter"
ssh-agent MY_HOME_DIR/ondemand/dev/remote_jupyter/bin/remote_jupyter ./pgo.yml 
echo "Jupyter job is done!"

The pgo.yml contains necessary PBS job parameters at the remote cluster which are specified by the user at the OOD session config page. The command “remote_jupyter” starts the remote JupyterLab server with the configure file “config.py” and then conduct the ssh port forwarding at the OOD node.

The config.py file:

c.NotebookApp.ip = '*'
c.NotebookApp.port = 29295
c.NotebookApp.port_retries = 0
c.NotebookApp.password = u'sha1:7SU3hQY0cqH1jMYF:2cac5f8fd37ba1482692894e3117451d83657c85'
c.NotebookApp.open_browser = False
c.NotebookApp.allow_origin = '*'
c.NotebookApp.notebook_dir = '/home/xyz'
c.NotebookApp.disable_check_xsrf = True

Both pgo.yml and config.py are created in before.sh.erb.

The log file “output.log”:

Script starting...
Waiting for Jupyter Notebook server to open port 29295...
TIMING - Starting wait at: Sat Nov 20 12:47:08 AEDT 2021
running jupyter
Discovered Jupyter Notebook server listening on port 29295!
TIMING - Wait ended at: Sat Nov 20 12:47:29 AEDT 2021
Generating connection YAML file...

It is noticed that the function “port_used_nc” can not discover the forwarded port 29295 so I have to use “port_used_lsof” to discover it and then generate the connection YAML file.

I can manually access the remote JupyterLab server with the url “localhost:29295” at the local OOD node. However, I get the “Failed to connect” error after clicking “Connect to Jupyter” button at the OOD session page.

Please let me know if you need more information. Thanks.