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 and, since it is being proxied, the --no-ssl command was used. Let’s also assume the Apache proxy serves its content at example.com.

<IfModule mod_proxy.c>
    Redirect /jupyter /jupyter/
    ProxyVia On
    ProxyRequests Off
    ProxyPass /jupyter/
    ProxyPassReverse /jupyter/
    ProxyPreserveHost on
    Header edit Origin "example.com"
    RequestHeader edit Origin "example.com"
    Header edit Referrer "example.com"
    RequestHeader edit Referrer "example.com"
    <Proxy *>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    <Location ~ "/jupyter/(user/[^/]*)/(api/kernels/[^/]+/channels|terminals/websocket)/?">
        ProxyPass ws://
        ProxyPassReverse ws://

You will need the mod_proxy_wstunnel.

Related content