申請 免費的 https 證書 acme
阿新 • • 發佈:2020-12-24
如何申請免費的HTTPS證書
這裡用的是 使用 acme.sh 給 Nginx 安裝 Let’ s Encrypt 提供的免費 SSL 證書,具體步驟如下:
- 建立資料夾
mkdir -p /var/www/a.com/.well-known/
mkdir -p /etc/letsencrypt/live/a.com/
- 配置nginx
location ^~ /.well-known {
alias /var/www/a.com/.well-known;
}
- 申請證書
./acme.sh --issue -d a.com -w /var/www/a.com
./acme.sh --installcert -d a.com --keypath /etc/letsencrypt/live/a.com/privkey.pem --fullchainpath /etc/letsencrypt/live/a.com/fullchain.pem
./acme.sh --renew -d a.com --force
- 配置ssl nginx
server {
listen 443 ssl;
server_name a.com;
charset utf-8;
ssl_certificate /etc/letsencrypt/live/a.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/a.com/privkey.pem;
}
- http 轉 https
server {
listen 80;
server_name a.com;
charset utf-8;
rewrite ^(.*)$ https://$host$1 permanent;
}
- 檢測報告
https://www.ssllabs.com/ssltest/index.html
-
續期
Let’s Encrypt 的證書有效期是 90 天的,你需要定期 renew 重新申請 -
精彩參考
https://ruby-china.org/topics/31983