Centos Apache通过Let’s Encrypt给网站配置Https

给自己的博客用上了 https,试过阿里云的免费证书,期限一年,到期后需手动续期。虽然Let’s Encrypt的证书期限只要三个月,但考虑到可以自动续期,所以爱易默博客还是配置的Let’s Encrypt免费证书。

参考: certbot官方教程

Centos Apache通过Let’s Encrypt给网站配置Https

安装certbot

sudo yum install certbot python2-certbot-apache

准备配置

Certbot有一个Apache插件,支持多平台,可以实现证书的自动安装。

sudo certbot --apache

运行此命令就可以获取证书,并让Certbot根据你的输入设定自动编辑Apache配置,避免人为配置的繁琐操作。 如果你希望手动更改Certbot和Apache配置,则可以使用certonly子命令:

sudo certbot --apache certonly

博主小C采用的是第一种自动配置,详情如下:
Let's Encrypt Https Centos ApacheLet's Encrypt Https Centos Apache

实际使用下来可以看到,Certbot Apache插件有一套完善的针对Apache服务器的https自动配置程序(包括重定向等功能),使用它可以极大简化配置过程

自动续期

可以将Certbot配置为在证书过期之前自动续订证书。 由于Let’s Encrypt的加密证书可以使用90天,因此最好利用此功能。可以通过运行以下命令来测试证书的自动续订:

sudo certbot renew --dry-run

如果一切都工作正常,就可以通过添加运行以下命令来安排自动续订:

certbot renew

注意:
如果您正在设置cron或systemd作业,我们建议每天运行两次(在您的证书需要续订或撤销之前,它不会执行任何操作,但定期运行会使您的站点有机会保持在线状态,以防Let’s Encrypt因为某些错误或原因发生了加密证书的撤销。 建议在一小时内为您的续订任务选择一个随机时间。

根据Let’s Encrypt官方的建议,我们可以运行以下命令执行自动续期任务

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew" | sudo tee -a /etc/crontab > /dev/null

Let's Encrypt Https Centos Apache

特别提示:
只要当前网页内的全部站内链接都通过https形式访问时,浏览器网站信息里才会有一个加锁图标,表示连接已完全加密,不然都会提示内容是不安全的
0 0 投票数
喜欢就给个好评吧!
赞(1) 打赏
未经允许不得转载:爱易默博客 » Centos Apache通过Let’s Encrypt给网站配置Https
订阅评论
提醒
guest

0 评论
内联反馈
查看所有评论
免责声明:本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除,若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,与本站无关。本站发布的内容若侵犯到您的权益,请联系站长删除,我们将及时处理! Disclaimer: Most of the download resources on this site are collected on the Internet, and are only used for learning and communication. The copyright belongs to the original author. Please consciously delete within 24 hours after downloading. If you use it for commercial purposes, please purchase the original version. If the content posted on this site violates your rights, please contact us to delete it, and we will deal with it in time!

联系我们 Contact us

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

0
希望看到您的想法,请您发表评论x