搭建Jupyter Notebook服务器

python3 -m pip install jupyter

(py3) [root@nginx test]# python 
Python 3.6.6 (default, Aug 13 2018, 18:24:23) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from IPython.lib import passwd
>>> passwd()
Enter password: 
Verify password: 
'sha1:97a35023d94d:138aa302a6d3b83d8856baa64efdcea3c6d46359'
>>> 


# jupyter notebook --generate-config --allow-root
# vim /root/.jupyter/jupyter_notebook_config.py


# jupyter notebook password
Enter password: 
Verify password: 
[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json


# jupyter notebook --ip=0.0.0.0 --no-browser --allow-root  > /tmp/jupyter.log 2>&1 &



# jupyter notebook list
Currently running servers:
http://0.0.0.0:8888/?token=4eba2529552040a0c482f4e130210053b01db68ba957b3f8 :: /opt/test

Nginx 配置

server {
    listen 80;
    server_name py.yjsec.com;
    location / {
        proxy_pass         http://localhost:8888/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
    }
}

重启Nginx服务让设置生效。
$ sudo nginx -s reload

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注