1. 首先需要一個(gè)免費(fèi)的 ssl 證書(shū)
本文使用的是 Let's Encrypt 免費(fèi)的 SSL 證書(shū)
關(guān)于其他證書(shū)選擇,點(diǎn)我
2. 然后按照官網(wǎng)的步驟添加證書(shū)
安裝 certbot
certbot 官網(wǎng) 可以選擇自己對(duì)應(yīng)的系統(tǒng),本文是 centos7
安裝 certbot 的 nginx 配置工具
$ yum -y install yum-utils
$ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
$ sudo yum install certbot-nginx
最好關(guān)閉防火墻 systemctl stop firewalld
進(jìn)行自動(dòng)配置 nginx
$ sudo certbot --nginx
證書(shū)過(guò)期自動(dòng)續(xù)期
測(cè)試?yán)m(xù)期命令
$ sudo certbot renew --dry-run
如果不報(bào)錯(cuò),在系統(tǒng)定時(shí)任務(wù)中添加續(xù)期命令
$ crontab -e
添加內(nèi)容:[每3個(gè)月1號(hào)更新證書(shū)]
0 0 1 */3 * certbot renew
保存