jupyterhub搭建及配置
官方文档
https://jupyterhub.readthedocs.io/en/latest/reference/technical-overview.html
找一台linux服务器专门用于jupyterhub的搭建
用root账号启动jupyterhub,jupyterhub的账号系统直接与linux的账号相关
为了实现跨域跳转登录
jupyterhub_config.py配置文件内容增加:
# 登录后默认看到的页面
c.Spawner.default_url = '/tree/'
# 跳转路由
c.JupyterHub.base_url = u'/jupyter/'
c.JupyterHub.bind_url = 'http://127.0.0.1:8000/jupyter/'
# 允许跨域,模拟登陆生成cookie的时候会用到
c.Spawner.args = ['--NotebookApp.allow_origin=*']
c.JupyterHub.tornado_settings = {
'headers': {
'Access-Control-Allow-Origin': '*',
nginx代理配置
location /jupyter/ {
# 跨域配置
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
# jupyter地址
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-Scheme $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# ws配置
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 120s;
proxy_next_upstream error;
jupyter中使用matplotlib
调中文字体:https://blog.csdn.net/qq_41770424/article/details/115708626