我的博客
欢迎来到我的博客
bunny.icu

nginx配置jupyter反向代理

nginx配置jupyter反向代理

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

版权声明


本作品系原创, 转载须遵循 CC BY-NC-ND 4.0 许可协议
本文标题:nginx配置jupyter反向代理
本文链接:https://www.bunny.icu/archives/1691

推荐文章

发表评论

textsms
account_circle
email

bunny.icu

nginx配置jupyter反向代理
nginx配置jupyter反向代理 jupyter配置 修改jupyter配置文件,使其允许跨域访问 vim ~/.jupyter/jupyter_notebook_config.py c.NotebookApp.ip='0.0.0.0' c.NotebookApp.open_browse…
扫描二维码继续阅读
2023-04-12