Jupyter-server-proxy: deployKF (Kubeflow) JupyterLab notebooks and base_url issues

I am using Jupyter Server Proxy extension to proxy port 4040 for the Apache Spark UI in our Kubeflow JupyterLab 3.6.8 notebook environment.

I can access the proxy port using https://my.domain.com/notebook/namespace/notebook_name/proxy/4040/jobs/ perfectly fine, however, when I use the launcher icon option, I get a strange redirect that sends me to http://my.domain.com:443/notebook/cl-admin/test/spark_ui/jobs/.

My config for the proxy and launcher icon looks like this, I’ve also tried toggling absolute_url flag, with no change in beahviour.

c.ServerProxy.servers = {
    "spark_ui": {
        "port" : 4040,
        "absolute_url": False,
        "launcher_entry": {
            "enabled": True,
            "icon_path": "/etc/jupyter/spark_ui.svg",
            "title": "Spark UI"
        },
        "new_browser_tab": True
    }
}

The deployKF Istio service mesh configuration does URL rewriting for paths with /notebook in it to hit the notebook VirtualService and route to the notebook service in Kubernetes. It seems like the Jupyter Proxy Server Launcher icon URL is captured by the rewrite rule but fails due to the protocol, if I could make it force HTTPS it will likely work.

I’m wondering if there is a way to set an absolute URL or custom base_path for the launcher icon. The base_url that the shortcut is generating ends up sending me to an HTTP URI instead of HTTPS, which seems like is coming from JupyterLab configuration somewhere or my container environment. I can see I can specify custom launch commands, but I’m not sure how to build this up with the basic proxy functionality, which works fine if I manually type the path.

Any assistance with getting this working would be appreciated, in the past I had used separate launcher icon plugin, but it throws many errors on startup of the notebook server in JupyterLab 3.6.8 due to it depending on specific JupyterLab Python packages, so using the inbuilt launcher icon would be ideal.

The launcher should send you to
https://my.domain.com/notebook/namespace/notebook_name/spark_ui/

If you’re being redirected to a http address that’s most likely coming from Spark or Istio, not Jupyter. What happens if you run a dummy HTTP server such as python -mhttp.server 4040 instead of the spark UI?

Hi manics,

Thanks for the suggestion. Yes, this is working fine. This must be settings regarding the Spark UI. I will try setting spark.ui.reverseProxyUrl on my Spark cluster and see how that ends up.

Kind regards,
Berg

So I figured out if I access https://my.domain.com/notebook/namespace/notebook_name/spark_ui/jobs/ everything works fine. As soon as I go to the top page of the Spark UI notebook/namespace/notebook_name/spark_ui/, that’s where the redirect occurs, and I end up in a bit of a mess due to both the Istio VirtualServer redirect and Spark UI redirect getting confused with the base protocol.

I went down some big rabbit holes with the Spark UI proxy settings and Istio VirtualService redirect rule settings, but in the end, I figured out if I just append the /jobs/ resource to the Spark UI launcher using the path_info attribute, magically everything starts working when I have the Spark config spark.ui.proxyRedirectUri: / set with no other proxy related settings configured or enabled.

c.ServerProxy.servers = {
    "spark_ui": {
        "port" : 4040,
        "absolute_url": False,
        "launcher_entry": {
            "enabled": True,
            "icon_path": "/etc/jupyter/spark_ui.svg",
            "title": "Spark UI",
            "path_info": "spark_ui/jobs/"
        },
        "new_browser_tab": False
    }
}

I had been reading the Spark UI not accessible issue on the Jupyter Proxy Server extension GitHub repo, I’ve added a comment there on my findings.

Thanks for helping to point me in the right direction manics :slight_smile:
Greatly appreciated to have this elegant solution for our customers.