為 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM