0

I am trying to connect my jupyter notebok server (:8888 port) via reverse proxy server

I have such rules:

ProxyPass "/serv8888"  "http://localhost:8888"
ProxyPassReverse "/serv8888"  "http://localhost:8888"

ProxyPass "/"  "http://localhost:80"
ProxyPassReverse "/"  "http://localhost:80"

but when I connect to http://localhost/serv8888 it redirects internally to http://localhost:80/tree and basically I get http://localhost/tree and it does not work because I need to get

http://localhost/serv8888/tree what also means internally http://localhost:8888/tree

How to make it working? Please help me, I spent two days and almost gave up

user548395
  • 1
  • 1
  • 2

2 Answers2

0

The problem is that your "jupyter notebook server"'s internal redirect is attempting to undo what the proxy-pass is trying to do. ProxyPass does not re-write content returned by the proxy's site. It simply proxies communication to another web server. If that other web server says go to "/some/url"... proxy pass will not change that.

You need to modify the jupyter's config and specify the NotebookApp.base_url to "/serv8888/"... and then proxypass will work for you.

TheCompWiz
  • 7,409
  • 17
  • 23
  • Thank you for your answer, but it is not enough for me. I want to have not only jupyter on the server, but also other servers which I will access like http://localhost/server1, http://localhost/server2, etc. I've found `ModRewrite` but with my skills a string `RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1` looks like a magic – user548395 Nov 13 '19 at 16:24
  • again, the child servers need to either *not* write URLs assuming they are hosted at "/", or you need to specify that the base URL is located elsewhere. If this is not sufficient for you, you need to ditch apache's `proxypass` and look at an actual cluster-framework that is capable of rewriting http content on the fly. I believe `squid` and other similar frameworks will suit your needs better. – TheCompWiz Nov 13 '19 at 16:35
  • ... and if you DO configure the base_url on your child-servers, you can host as many "servers" using `proxypass` as you want. – TheCompWiz Nov 13 '19 at 16:53
  • If I do not have any option to configure base urls of other servers? Is it possible to have another approach? And what is wrong with the usage of `RewriteRule` – user548395 Nov 14 '19 at 07:48
  • Nothing is wrong, with the rules, but the links (a hrefs, script src tags, 301 redirects, etc...) sent by the child-server will all return data using "/" as a reference. So, web-pages will includes a href="/something" not a href="/serv3888/something. Javascript src files will be reffered to as "/js/something" not "/serv3888/js/something". That's what YOUR child server returns. Apache does not modify content being sent by that server. – TheCompWiz Nov 14 '19 at 18:44
0

Answer:

use ProxyHTMLEnable On to change the html on the fly

user548395
  • 1
  • 1
  • 2