nginx反向代理jupyter,无法创建文件,代码块无法运行

多人使用一台服务器作为jupyter-notebook后端时, 或想将jupyter-notebook整合到已有的网络服务时, 或jupyter开启端口无法暴露在外网时, 可以使用nginx进行反向代理.

  • 如需使用服务器子地址访问jupyter, 例如: http://localhost/notebook/
    需要修改 ~/.jupyter/jupyter_notebook_config.py文件:
    c.NotebookApp.base_url = '/notebook/'
  • 配置nginx(>=1.3)
    # 若使用了NAT, 访问时要访问完整url, 最后的/不可省略
    location /notebook/ {
        proxy_pass http://localhost/notebook; #这里是能访问到jupyter的根url
        
        #这里和浏览器地址栏(访问nginx)输入的 主机:端口 保持一致 (80或443可以省略端口)
        proxy_set_header Host $host:$server_port; 
        
        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;

        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_read_timeout 120s;
        proxy_next_upstream error;
    }
发布了4 篇原创文章 · 获赞 3 · 访问量 766

猜你喜欢

转载自blog.csdn.net/weixin_39630484/article/details/105691704