这个jupyterhub自带了notebook和jupyterlab
先创建一个ubuntu18.04容器
docker run -d --hostname jupyterlab-server --name jupyterhub -p 83:8000 -i -t ubuntu:18.04 /bin/bash
#然后进入容器
docker exec -it jupyterhub /bin/bash
#按照正常方法安装anaconda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2019.10-Linux-x86_64.sh
bash Anaconda3-2019.10-Linux-x86_64.sh
conda install -c conda-forge jupyterhub
然后进行配置
注意c.JupyterHub.ip = 'your-ip'
不要填127.0.0.1(不然访问不了)
其余随便
然后chmod -R 777 /home
(很重要不然会500)
就可以了
说一下踩过的坑:
1. c.JupyterHub.ip = ''
要是设成127.0.0.1,反代之后就无法访问(refused)
2. 以/home目录存放文件时,没有chmod -R 777 /home 则报500 错误
3. c.Spawner.ip = '*'
则报503
4.上述一切做好后,会发现连不上内核??因为反代没设置好。需要在nginx主配置http里加
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
反代配置为:
#PROXY-START/
location /
{
proxy_pass http://127.0.0.1:83;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
add_header X-Cache $upstream_cache_status;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
#Set Nginx Cache
add_header Cache-Control no-cache;
expires 12h;
}
#PROXY-END/
配置文件:jupyterhubconfig.zip