Deploying JupyterHub behind an Apache reverse proxy’s subdirectory
JupyterHub supports deployment behind a reverse proxy and even instructs how to do so behindnginx in its manual. I was unable to find documentation about how to do this serving the content from a reverse proxy subdirectory.
Since there’s been a long time since I worked as a sysadmin and, therefore, I tend to forget these things, here hoes my documentation, in the hopes it will be useful to someone else.
Let’s assume JupterHub is running in a machine whose IP is
10.0.0.1 and, since it is being proxied, the
--no-ssl command was used. Let’s also assume the Apache proxy serves its content at
You will need the
<IfModule mod_proxy.c> Redirect /jupyter /jupyter/ ProxyVia On ProxyRequests Off ProxyPass /jupyter/ http://10.0.0.1:8000/jupyter/ ProxyPassReverse /jupyter/ http://10.0.0.1:8000/jupyter/ ProxyPreserveHost on Header edit Origin "example.com" 10.0.0.1:8000 RequestHeader edit Origin "example.com" 10.0.0.1:8000 Header edit Referrer "example.com" 10.0.0.1:8000 RequestHeader edit Referrer "example.com" 10.0.0.1:8000 <Proxy *> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Proxy> <Location ~ "/jupyter/(user/[^/]*)/(api/kernels/[^/]+/channels|terminals/websocket)/?"> ProxyPass ws://10.0.0.1:8000 ProxyPassReverse ws://10.0.0.1:8000 </Location>