https證書申請
下面介紹兩種比較簡單的申請方式:
使用網站
https://freessl.cn/ 在線免費申請有效期爲一年的證書。
**獲取certbot客戶端**
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
停止nginx/apache
systemctl stop nginx
生成證書
./certbot-auto certonly --standalone --email 你的郵箱地址
-d 你的域名地址
當前網站有多個域名時需在後面增加,例如:
./certbot-auto certonly --standalone --email 你的郵箱地址
-d 你的域名1
-d 你的域名2
查看生產的證書
tree /etc/letsencrypt/live/
將證書用於nginx
添加到server 字段下
listen 443 ssl http2;
server_name domain_name;
root /usr/share/nginx/html;
ssl_certificate /etc/letsencrypt/live/domain_name/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain_name/privkey.pem;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
目前已經配置好https了,下面進行自動續期操作
將下面內容添加到任務計劃就可以自動續期了。
0 0,12 python -c 'import random; import time; time.sleep(random.random() 3600)' && certbot renew
啓動nginx/apache
systemctl start nginx
作者:1198553937