jupyter/dashboards_server

Serve dashboards with a prefix

mao-liu opened this issue · 3 comments

Hi,

I recently tried to collect the several web services under one Apache server, one of them is the dashboards server. Each of these services run on a different localhost port, and Apache acts as the reverse-proxy to direct different URLs to different ports based on the prefix.

e.g.
my.domain.com/jupyter --> http://127.0.0.1:9500/jupyter, jupyter hub serving on localhost:9500/jupyter
my.domain.com/jenkins --> http://127.0.0.1:8080/jenkins, jenkins serving on localhost:8080/jenkins
...`

I cannot find a way to specify a prefix for the dashboards server. I can only get it to serve on http://host:port, whereas I would like to be able to serve at http://host:port/prefix.

My initial dig into this points to some changes required in the templates, particularly the way /css and /components are linked in the templates.

Is this an easy thing to implement? I am not very familiar with node/express, but will be happy to have a go at a pull request.

Cheers,

@ch41rmn We'd love a PR if you're willing to tackle this.

You are correct that the dashboard server is not currently relocatable under different paths. I'm pretty certain there is no major impediment preventing it, just a matter of finding all the spots that might break. The ones that come to mind are:

@jhpedemonte, @dalogsdon can you think of other spots that would need updating?

I think those mentioned by @parente are the main points.

  • For templates (mainly the listing view but possibly others) we are using Handlebars. You will probably need to pass the prefix when rendering. In the template, if a variable isn't set, it will resolve to an empty string.
  • For the router, I'd vote for a root router. That way it's only in once place and you don't have to think about the prefix in the child routes.
  • The config parameter PUBLIC_LINK_PATTERN will need to include the prefix. See config.json. The config uses Hjson

Fixed by #292.