Apache Reverse Proxy – Proxypass Changing URL

apache-2.4PROXYreverse-proxyurl-routing

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

Best Answer

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.