nginx配置jupyter反向代理
jupyter配置
修改jupyter配置文件,使其允许跨域访问
vim ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.open_browser = False
c.NotebookApp.allow_origin = '*' # allow cors
c.NotebookApp.notebook_dir = "/root/jupyter"
启动jupyter
jupyter notebook --allow-root
nginx配置
使nginx支持websocket
server {
listen 443 ssl;
server_name jupyter.xxx.com;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains;preload" always;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-Xss-Protection 1;
location / {
proxy_http_version 1.1;
proxy_set_header Accept-Encoding gzip;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 120s;
proxy_next_upstream error;
proxy_connect_timeout 3s;
proxy_pass http://localhost:8888;
}
}
重启nginx
nginx -s reload
Reference
配置 jupyter notebook 允许远程访问
nginx代理jupyter notebook v1.0.0 http websocket
发表评论