使用certbot进行免费域名SSL证书的申请和更新。
因为我的os版本比较低,所以是用snap进行安装,高版本的Ubuntu系统可以直接apt install certbot就能安装了。
1 2 3 4 5 6 7 8 |
apt install snapd snap install certbot snap install --classic certbot /snap/bin/certbot ln -s /snap/bin/certbot /usr/bin/certbot which certbot certbot --nginx # 生成证书并更新到Nginx配置文件 less /etc/nginx/sites-enabled/default # 检查是否生成了ssl相关配置,可以搜索Certbot关键字 |
最后配置定时任务crontab,定期执行certbot renew操作即可定期更新域名证书。
然后就可以使用https访问域名了,http也会默认跳转到https。