Follow me on GitHub

为 Jupyter 添加免费的 TLS SSL 证书

为 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

注意:

  1. 现在 let's encrypt 已经支持通配符了,意味着一个证书通天下。、
  2. 需要完成 DNS 的 txt 记录解析,根据提示做就好
  3. 生成的文件位于 /etc/letsencrypt/archive/<your domain-name> 目录下
    • 我们需要公钥 cert1.pemprivkey1.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

(完)
posted @ 2020-03-29 14:16  季文康  阅读(868)  评论(0编辑  收藏  举报