How to redirect in repo2docker / jupyter-server-proxy / myBinder Containers?

I am trying to setup a repo2docker Container with two active server processes inside.
On the one hand it serves a jupyter notebook server and on the other a login gui. To serve the login gui i’m using a start skript, that simply starts the login gui server in the background.
The login gui http port serves on port 1709 and i can access that port via the Jupyter-Server-Proxy by substituting /tree in the url with /proxy/1709/.

The Problem is, that if i access it, i get redirected to /signin. In docker2repo this redirect is attached directly behind the base url. That substitutes the proxying /proxy/1709. The same problem also occurs for all the static files on the /static route.

In mybinder this problem is even worse, because it substitutes the long user specific my binder url and then after it failed, it tries to redirect to /hub/signin.

Is it possible to configure a repository in a way, that enables me to add a /proxy/1709/ in front of all the redirects that are carried out by our internal GUI without changin the redirects inside the GUIs Server itself? That means, just by configuring the jupyter-server-proxy?

I don’t have a solution but I’ve been trying to articulate a similar issue that I’m facing so I can then try to solve it, the issue being that:

a) I want to add a link in a notebook to a Jupyter-server-proxied service, and
b) I want that link to work wherever I run the notebook.

If I add a link to /proxied_service, this breaks in MyBinder because the user root directory is some way down the Binder/Jupyterhub path.

If I make an explicit relative path to the proxied service, ../../proxied_service depending on the location of my notebook, the path will break if I try to use the same link in a notebook at a different depth, or move the notebook into a parent or child directory.

Is this the same as the issue you’re facing?

Not really. But adding a link i imagine quite difficult, too, because the url the url changes everytime you are opening a new mybinder instance.

My problem are the redirects from another service that runs inside the container. It has to run locally in the container because a python package inside the jupyter notebook has to access its API.

This is my repository: https://github.com/JulianOestreich90/mybinder_notebooks

The biggest problem are the static files inside the user frontend of the other background service which is started in the start skript. The browser will look for the static files under https://hub.gke.mybinder.org/static/... where it obviously can’t find them. Instead it shall look under https://hub.gke.mybinder.org/user/....../proxy/1709/static/....

jupyter-server-proxy has options that govern whether a full or partial path is passed to the backend, and whether or not headers indicating the original base path are set. See the documentation for absolute_url and /proxy/absolute. Many web-app frameworks will take note of either the absolute path, or the headers if the paths aren’t absolute, when rendering links.

1 Like