Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxying relative URLs in redirects #88

Closed
ian-r-rose opened this issue Jan 20, 2019 · 9 comments
Closed

Proxying relative URLs in redirects #88

ian-r-rose opened this issue Jan 20, 2019 · 9 comments

Comments

@ian-r-rose
Copy link
Collaborator

In gitter I was chatting with @yuvipanda about the possibility of proxying one version of JupyterLab (specifically using --dev-mode) underneath the main one running in binder. https://gitter.im/jupyterhub/binder?at=5c42411983189945240fa7af

In trying this I ran into an issue with redirects. The proxied notebook server returns several redirects towards the default page, but when these redirects (e.g., to /lab), are received by the outer notebook server, they are then used to proxy to a page there rather than a page on the proxied server. This is not the effect I was looking for, and it seems to make pages in the proxied server entirely inaccessible if there is a redirect in the way.

This can be tested locally in this branch by running jupyter notebook --config=binder/config.py. Any thoughts on how to move forward?

I don't know a ton about the right language around proxies, so apologies if this is using the wrong language or is easily fixable :)

@manics
Copy link
Member

manics commented Jan 21, 2019

Can you give #85 a go? It should pass the external URL directly to the backend.

@yuvipanda
Copy link
Contributor

@ian-r-rose I think what you need is base_url, rather than absolute URLs. I made a PR ian-r-rose/jupyterlab#1 that sets base_url, check it out and let me know if that works.

@ian-r-rose
Copy link
Collaborator Author

@manics Thanks for the tip! I'll give that a shot.

@yuvipanda
Copy link
Contributor

@manics is absolutely right and this is fixed by passing absolute URL back. I'll play around with merging #85 today.

@yuvipanda
Copy link
Contributor

And apologies for going on a tangent instead of investigating your PR, @manics!

@psychemedia
Copy link

psychemedia commented Feb 1, 2019

I'm not sure I understand the absolute_url setting. eg trying it set to True when trying to proxy datasette gets me into a redirect loop?

And if I set it to False, then things break because style files and links are resolved back to / rather than relative to the proxied path?

@psychemedia
Copy link

psychemedia commented Feb 2, 2019

I was probably overtired working on these last night and quite possibly missed something obvious, but here are some variously broken examples in terms of static referencing:

  • OpenRefine: works fine down the openrefine/ path and proxy/3333/ path but breaks on proxy/3333 (no trailing slash; see also Issue with link '/' stripping? #37);
  • datasette: styling is broken on the alias path; setting 'absolute_url':True results in an infinite redirect; datasette does look like it might support static path setting but I think I was thrashing in an infinite loop of my own confusion about what bits did what last night and could't figure it out!
  • franchise: I've messed up the app start somewhere, but starting on the terminal (cd franchise/bundle && python -m http.server 8899) behaves like OpenRefine: fine on proxy/8899/ but broken without the trailing slash on proxy/8899; (there is another issue with actually trying to connect to a db other than SQLite but that's a franchise issue);
  • Apache Drill: at the moment, this still needs starting from the terminal (/home/jovyan/apache-drill-1.15.0/bin/drill-embedded; it may take a moment or two to start up...; default port is 8047). Styling is broken on both proxy/8047 and proxy/8047/;
  • pgadmin4: pgadmin doesn't seem to run; starting the pgadmin server manually from the terminal (eg PGADMIN_PORT=8899 python /srv/conda/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py) seems to start but I get a not found error on proxy/8899.

If I can identify the different issues and fixes, I'll try to write up some docs about how to go about setting proxied services like these up and the likely gotchas along the way. It may be that there are various things wrong in any particular example, with me trying to fix one problem when it was actually another... If I can bootstrap from working examples, (or break working examples to see how they fail) that often helps!

Is there an alternative to proxy/PORT that can be used to test the alternative behaviour (I think I saw proxy-abs mentioned at one point?)?

Another observation that falls out of the above is that it is often much easier to use docker-compose to link a Jupyter notebook server container to other bespoke, standalone app containers (eg notebook+postgres+pgadmin containers, or notebook+zookeeper+drill containers). Is there any discussion about relative merits of each approach (repo2docker versus docker-compose) and how they might fit into different workflows / use contexts?

@manics
Copy link
Member

manics commented Feb 4, 2019

  • /proxy/12345/sub/path will rewrite the proxied URL so the application see /sub/path, but with HTTP headers to indicate it's running under /proxy/12345
  • /proxy/absolute/12345/sub/path passes the full URL directly so the application sees /proxy/absolute/12345/sub/path and no special headers are set

Also see my reply on https://discourse.jupyter.org/t/pgadmin-in-mybinder/365/6

@ian-r-rose
Copy link
Collaborator Author

@yuvipanda This was fixed by #85, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants