RSSAmplifier

pablotron.org · Mar 31, 2025

JupyterLab Reverse Proxying in Apache

0
Sign in to vote or save

pablotron.org

I’ve been using the SageMath kernel in JupyterLab quite a bit lately. I wanted to reverse proxy through an Apache vhost to JupyterLab. The documentation to do this is surprisingly elusive.

Here is a working example:

<VirtualHost *:443>
  ServerName sage.example.com

  # proxy http and websocket to http://localhost:1980/
  # note: in apache 2.4.47+, use upgrade=websocket to proxy websocket
  ProxyPass "/" http://localhost:1980/ upgrade=websocket
  ProxyPassReverse "/" http://localhost:1980/ upgrade=websocket

  # preserve Host header in proxied requests
  ProxyPreserveHost on

  # ... common vhost configuration elided
</VirtualHost>

Notes:

  1. Add upgrade=websocket to ProxyPass and ProxyPassReverse. Needed to proxy WebSocket connections in Apache 2.4.47+. See the Protocol Upgrade note in the mod_proxy documentation for additional details.
  2. Enable ProxyPreserveHost. This preserves the Host header in proxied requests and it is needed to prevent cryptic server-side origin errors.

The target JupyterLab instance is running in a Podman container, like so:

podman run -d -p 1980:8888 \
  -v sage:/home/sage/work \
  --restart=on-failure \
  --name sage \
  docker.io/sagemath/sagemath sage-jupyter

Read the original on pablotron.org

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.