文章15 | 阅读 4716 | 点赞0
Let’s Encrypt 是一个于2015年推出的数字证书认证机构,将通过旨在消除当前手动创建和安装证书的复杂过程的自动化流程,为安全网站提供免费的SSL/TLS证书,它有个赞助商 电子前哨基金会,让网站安装证书十分简单,只需要使用电子前哨基金会EFF的 Certbot。
PS:阿里云服务器,需要先在服务器网络安全规则中开放 443 端口
让我们来安装证书吧:
#在location下添加重定向,访问 www.zypcy.cn时会自动跳转到 https://www.zypcy.cn
location / {
# Redirect non-https traffic to https
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.zypcy.cn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.zypcy.cn/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
0 0 1 * * /usr/bin/certbot renew --force-renewal
5 0 1 * * /usr/local/nginx/sbin/nginx -s reload
注:crontab 中有六个字段,其含义如下:
第1个字段:分钟 (0-59分钟)
第2个字段:小时 (0-23小时)
第3个字段:日期 (1-31号)
第4个字段:月份 (1-12月)
第5个字段:一周当中的某天 (0-7 [7 或 0 代表星期天])
现在访问 www.zypcy.cn,浏览器自动转换为 https://www.zypcy.cn 了
之前我不太清楚 crontab -e 命令
因此有一个疑惑,怎么验证 crontab -e 周期性执行任务是否会运行,下面进行验证,目标:每分钟打印一段话
使用:certbot certonly --webroot -w /home/fast/res/ -d your.domain.com
安装成功后,默认会在 /etc/letsencrypt/live/your.domain.com/ 会生成CA证书。
server {
listen 80;
server_name res.csxiuneng.com;
location / {
alias /home/fast/res/;
autoindex on;
}
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/res.csxiuneng.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/res.csxiuneng.com/privkey.pem; # managed by Certbot
}
参考了一些博客:
https://coolshell.cn/articles/18094.html
https://zning.me/15424636102403.html
https://github.com/zning1994/certbot-letencrypt-wildcardcertificates-alydns-au
https://blog.csdn.net/liaoyanyunde/article/details/86572370
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://zhuyu.blog.csdn.net/article/details/93994697
内容来源于网络,如有侵权,请联系作者删除!