Certbot Standalone 五分钟申请免费 SSL 证书完整教程【免费下载链接】certbotCertbot is EFFs tool to obtain certs from Lets Encrypt and (optionally) auto-enable HTTPS on your server. It can also act as a client for any other CA that uses the ACME protocol.项目地址: https://gitcode.com/gh_mirrors/ce/certbot临时测试机刚上线没装 Nginx业务方却要求今晚就开 HTTPS。不用先装 Web 服务器用 Certbot Standalone 就能申请到免费 SSL 证书它自己起一个临时 HTTP 服务完成域名验证拿到证书后立刻退出。从一条命令到证书落地五分钟能跑完。先判断Standalone 是不是你的环境该用的模式结论先说80 端口能空出来且没有必须常驻的 Web 服务就选它。80 端口当前空闲或能临时停掉占用服务适用机器没装 Web 服务器装一个也不划算适用已有 Web 服务器在跑且能写它的网站根目录换 webroot不中断服务需要通配符证书或 80 端口彻底开不了换 dns-01走 DNS 记录验证服务必须 7×24 不中断连停几秒都不行不适用⚠️ Standalone 验证期间独占 80 端口期间有服务占用会直接验证失败。规避动作申请前先停服务或用 --pre-hook 自动停。webroot 和 dns-01 的差别一句话带过webroot 往现有 Web 服务器的根目录写验证文件dns-01 改 DNS 记录两者都不需要独占 80 端口。五分钟流程一条命令到证书落地Standalone 申请证书的一条命令最简命令只有一行跑通就是成功certbot certonly --standalone -d example.com --email adminexample.com --agree-tos它让 Certbot Standalone 插件临时占用 80 端口完成验证证书落到 /etc/letsencrypt/live/example.com/不碰任何 Web 服务器配置。参数逐行拆解--standalone启用独立 Web 服务器模式certonly只申请证书不修改任何服务器配置-d指定域名可重复写多个如-d example.com -d www.example.com--email接收到期通知必填--agree-tos自动同意 Lets Encrypt 服务条款80 被占用时的非标准端口--http-01-port只改本地监听端口不改外部验证入口certbot certonly --standalone -d example.com --http-01-port 8080执行后 Certbot 改听 8080外部流量仍要从 80 进来再转到 8080。⚠️ ACME 验证服务器仍会连接服务器的 80 端口不做 80 → 8080 转发必然验证失败。规避动作先配好转发规则再跑命令。证书产物路径申请成功后文件默认在/etc/letsencrypt/live/example.com/fullchain.pem服务器证书 中间 CAprivkey.pem私钥权限要收紧cert.pem服务器证书单文件密钥算法方面2.0 默认 ECDSAsecp256r1 曲线。示例配置 certbot/examples/cli.ini 里用的是key-type ecdsa加elliptic-curve secp384r1要兼容旧设备就写rsa-key-size 4096。Standalone 申请失败怎么排查三个现场都出在 80 端口上逐个拆。80 端口被占用怎么解决报错原文Problem binding to port 80: Could not bind to IPv4 or IPv6.原因端口已被别的服务占走。修复sudo lsof -i :80找出进程systemctl stop nginx停掉它再申请成功后systemctl start nginx恢复服务。防火墙没放行 80 端口报错表现申请过程没有绑定错误挑战验证超时几分钟后失败。原因防火墙或云安全组没开 80验证流量进不来。修复入站规则加一条——协议 TCP、端口 80、源地址 0.0.0.0/0。Lets Encrypt 验证 IP 不固定别只对单一来源放行。多网卡绑定指定 IP表现机器有多块网卡Certbot 默认绑定错地址挑战请求落到错误的 IP 上。修复用--http-01-address指定绑定地址即certbot certonly --standalone --http-01-address 192.168.1.100 -d example.com。证书拿下来之后续期、备份、排障入口Lets Encrypt 证书有效期 90 天续期交给 cron80 被占用时用 hook 停启 nginx0 0 1 * * certbot renew --quiet --standalone --pre-hook systemctl stop nginx --post-hook systemctl start nginx这是一条 cron 任务每月 1 日 0 点检查 Lets Encrypt 自动续期续期前停 nginx完成后自动拉起。首次运行加--test-cert测试别在生产触发 Lets Encrypt 速率限制备份定期备份整个 /etc/letsencrypt/ 目录私钥和配置都在里面排障入口看 /var/log/letsencrypt/letsencrypt.log申请失败的原因全在这里收尾Standalone 适合临时服务、端口冲突的机器和 CI/CD 流水线里的证书自动化。完整参数查 certbot/docs/using.rst命令行直接跑certbot --help standalone看当前版本支持哪些选项。【免费下载链接】certbotCertbot is EFFs tool to obtain certs from Lets Encrypt and (optionally) auto-enable HTTPS on your server. It can also act as a client for any other CA that uses the ACME protocol.项目地址: https://gitcode.com/gh_mirrors/ce/certbot创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
阅读完成 · 觉得有帮助?