Jupyter 服务的 Nginx 配置

Posted by agentd on 09-24,2018

jupyter 配置

配置文件在 /home/user/.jupyter/jupyter_notebook_config.py

配置 jupyter 的路径

c.NotebookApp.base_url = '/jupyter/'

nginx 配置

jupyter 使用了 websocket 协议,所以需要配置支持 websocket。

    location /jupyter/ {
        proxy_pass http://jupyter;
        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;

        # 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;
    }

参考链接 Nginx 支持 WebSocket

本文链接 https://agentd.cn/archives/jupyter_nginx_conf 作者 agentd