1. 首先需要一个免费的 ssl 证书
本文使用的是 Let's Encrypt 免费的 SSL 证书
关于其他证书选择,点我
2. 然后按照官网的步骤添加证书
安装 certbot
certbot 官网 可以选择自己对应的系统,本文是 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
最好关闭防火墙 systemctl stop firewalld
进行自动配置 nginx
$ sudo certbot --nginx
证书过期自动续期
测试续期命令
$ sudo certbot renew --dry-run
如果不报错,在系统定时任务中添加续期命令
$ crontab -e
添加内容:[每3个月1号更新证书]
0 0 1 */3 * certbot renew
保存
网友评论