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:
- Add
upgrade=websocketto 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. - Enable ProxyPreserveHost. This preserves the
Hostheader 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
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.