#####Jupter 相关配置

1
2
3
4
5
6
7
# ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.port = 8878
c.NotebookApp.base_url = '/groot'
# 去除jupter密码设置
c.NotebookApp.password_required = False
c.NotebookApp.token = ''
c.NotebookApp.password = u''
Nginx相关配置

添加相关配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 添加一个upstream
upstream upstream_groot {
server localhost:8888;
keepalive 32;
}

location = /groot {
rewrite ^/(.*)$ $1/ permanent;
}
location /groot {
error_page 403 = @proxy_groot;
deny 127.0.0.1;
allow all;
# set a webroot, if there is one
root /some-webroot;
try_files $uri @proxy_groot;
}
location @proxy_groot {
#rewrite /groot(.*) $1 break;
proxy_read_timeout 300s;
proxy_pass http://upstream_groot;
# pass some extra stuff to the backend
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /groot/api/kernels/ {
proxy_pass http://upstream_groot;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
location ~ /groot/terminals/ {
proxy_pass http://upstream_groot;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
参考
  1. https://www.nathantsoi.com/blog/run-jupyter-notebook-behind-a-nginx-reverse-proxy-subpath/index.html

  2. https://www.pianshen.com/article/1434301772/