centos 7 配置certbot
snap方式安装certbot
certbot 是python 工具安装和升级容易造成包损坏等相关问题。
使用官方推荐方式安装 ,这里依赖了一个三方的环境隔离软件snap
https://certbot.eff.org/instructions?ws=other&os=centosrhel7
使用阿里云插件
sudo snap install certbot-dns-aliyun
sudo snap set certbot trust-plugin-with-root=ok
sudo snap connect certbot:plugin certbot-dns-aliyun
certbot plugins
配置密钥签发证书
certbot certonly --authenticator=dns-aliyun --dns-aliyun-credentials=/root/.certbot/credentials.ini -d test.nihao.cn -d "*.test.nihao.cn"
也可以选择maunal 的方式进行证书申请
certbot -d woaixuexi.cn --manual --manual-auth-hook 'sh /data/scripts/certbot_root_hook' --preferred-challenges http certonly
cat /data/scripts/certbot_root_hook
#!/bin/bash
function old {
path= /usr/local/nginx/html/.well-known/acme-challenge
cd $path
git pull origin master
touch ${CERTBOT_TOKEN}
git add ${CERTBOT_TOKEN}
git commit -m "${CERTBOT_DOMAIN} 提交认证文件 ${CERTBOT_TOKEN} "
git push origin master
}
function new {
echo ${CERTBOT_VALIDATION} > /usr/local/nginx/html/.well-known/acme-challenge/${CERTBOT_TOKEN}
}
new
--preferred-challenges 可以填写 dns 或者http。dns 方式通过dns txt记录进行验证;http 方式通过写入 .well-known/acme-challenge/plabXCawLKD3sEnfWxxxxxxxxxxxx 文件进行验证,但是验证完后还有查询下域名的A记录,国内有些cn 域名可能会出现以下报错,解决方案是找时间重试,或者在运营商那里提高自己dns服务器等级。
Detail: During secondary validation: DNS problem: query timed out looking up A for woaixuexi.cn
本文来自博客园,作者:萱乐庆foreverlove,转载请注明原文链接:https://www.cnblogs.com/leleyao/p/15786023.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义