關於let's encrypt和acme.sh的簡介
Let’s Encrypt is a free, automated, and open Certificate Authority.
acme.sh 實現了 acme 協議, 可以從 let‘s encrypt 生成免費的證書.
安裝,使用acme.sh
- 推薦使用root用戶安裝
sudo su root
- 安裝命令
curl https://get.acme.sh | sh
- 生成ssl證書
使用webroot方式
acme.sh --issue -d blog.lomot.cn --webroot /var/www/blog.lomot.cn/
或者可以使用nginx方式,具體還有其他的方法參考acme.sh項目的github
acme.sh --issue -d blog.lomot.cn --nginx
- copy證書
acme.sh --installcert -d blog.lomot.cn --key-file /etc/nginx/ssl/blog.lomot.cn.key --fullchain-file /etc/nginx/ssl/blog.lomot.cn.cer --reloadcmd "service nginx force-reload"
- 應用證書
這里只給出nginx的方法:
例如網址是blog.lomot.cn 在/etc/nginx/nginx.conf
中添加如下
server { listen 80; server_name blog.lomot.cn; rewrite ^(.*)$ https://$host$1 permanent; } server { listen 443; server_name blog.lomot.cn; ssl on; ssl_certificate /etc/nginx/ssl/blog.lomot.cn.cer; ssl_certificate_key /etc/nginx/ssl/blog.lomot.cn.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://localhost:3000; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
證書自動更新
目前證書在 60 天以后會自動更新, 你無需任何操作. 今后有可能會縮短這個時間, 不過都是自動的, 你不用關心.
更新acme.sh
目前由於 acme 協議和 letsencrypt CA 都在頻繁的更新, 因此 acme.sh 也經常更新以保持同步.
升級 acme.sh 到最新版 :
acme.sh --upgrade
如果你不想手動升級, 可以開啟自動升級:
acme.sh --upgrade --auto-upgrade
之后, acme.sh 就會自動保持更新了.
你也可以隨時關閉自動更新:
acme.sh --upgrade --auto-upgrade 0
引用
具體教程可以參考acme.sh的github
https://github.com/Neilpang/acme.sh
作者:lomot
鏈接:https://www.jianshu.com/p/8984bed9a784
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。