為 Jupyter 添加免費的 TLS SSL 證書
步驟一:生成 let's encrypt 證書
wget https://dl.eff.org/certbot-auto
chmod +x certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
certbot-auto certonly --manual -d *.example.com
注意:
- 現在 let's encrypt 已經支持通配符了,意味着一個證書通天下。、
- 需要完成 DNS 的 txt 記錄解析,根據提示做就好
- 生成的文件位於
/etc/letsencrypt/archive/<your domain-name>
目錄下- 我們需要公鑰
cert1.pem
和privkey1.pem
私鑰倆個文件
- 我們需要公鑰
步驟二:配置 Jupyter 使用 TLS 加密
$ jupyter notebook --generate-config
$ vim ~/.jupyter/jupyter_notebook_config.py
# Set options for certfile, ip, password, and toggle off
# browser auto-opening
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/fullchain.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/privkey.pem'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
c.NotebookApp.open_browser = False
# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 9999
步驟三:查看效果,盡情享用吧
參考文檔:
How To Generate Let’s Encrypt Wildcard SSL Certificate
Running a notebook server — Jupyter Notebook 6.0.3 documentation