Hello guys !
I have issues with running jupyterhub in Docker behind a proxy. I originally post it in github and people told me to post it here, as it more related to support than bug.
More specifically : I can’t create a file from the jupyter notebook (spawn by jupyterhub).
The error in the UI
The error in the console
[W 2020-11-19 20:49:22.157 SingleUserNotebookApp handlers:390] Blocking Cross Origin API request for /jhub/user/etienne/api/contents. Origin: https://DOMAIN-NAME, Host: localhost:8000
[W 2020-11-19 20:49:22.158 SingleUserNotebookApp handlers:613] Not Found
[W 2020-11-19 20:49:22.159 SingleUserNotebookApp log:181] 404 POST /jhub/user/etienne/api/contents (etienne@::ffff:172.17.0.1) 3.19ms
The same problem arise when I create a fake notebook.ipynb (using echo): the kernel won’t start (since it is launched from the same POST request on /api/sessions I guess)
My setup
- Jupyterhub is deployed using the Docker image https://hub.docker.com/r/jupyterhub/jupyterhub/ and the following command
docker run -p 8000:8000 jupyterhub/jupyterhub jupyterhub --url='http://:8000/jhub/' --NotebookApp.allow_origin='*' --NotebookApp.token='' --debug
- Apache used as reverse proxy config with the following config :
<VirtualHost *:80>
ServerName DOMAIN-NAME
</VirtualHost>
# For JupyterHub
RewriteRule /jhub/(.*) ws://localhost:8000/jhub/$1 [P,L]
RewriteRule /jhub/(.*) http://localhost:8000/jhub/$1 [P,L]
ProxyPass /jhub/ http://localhost:8000/jhub/
ProxyPassReverse /jhub/ http://localhost:8000/jhub/
<VirtualHost *:443>
ServerName DOMAIN-NAME
# Jupyterhub
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:8000/$1 [P,L]
<Location "/jhub/">
ProxyPreserveHost on
ProxyPass http://127.0.0.1:8000/jhub/
ProxyPassReverse http://127.0.0.1:8000/jhub/
</Location>
</VirtualHost>
- the bash command
sudo a2enmod ssl rewrite proxy proxy_http proxy_wstunnel
has been ran as indicated in https://jupyterhub.readthedocs.io/en/stable/reference/config-proxy.html
Also, not shown here but i tried to ass Header set Access-Control-Allow-Origin "DOMAIN-NAME"
at various location of my apache config without any success.
The config seems okay since it works on another VM of the same subnet but with JupyterHub installed manually (i.e not deployed using Docker).
The OS and the packages version
- OS: Ubuntu 18.04.3 LTS
-
notebook
version : 6.1.5 (installed using pip since not contains in the docker image) -
jupyterhub
version : 1.2.1.