TLDR: Turns out my OPNsense is blocking the DNS queries from Caddy so that Caddy can’t resolve https://acme-v02.api.letsencrypt.org to refresh the certificates.
Issue
突然发现所有页面的 HTTPS 证书都过期了,浏览器提示不安全。Caddy 服务在运行,但无法完成续期。
Debug
1. 查看 Caddy 日志
使用 journalctl 查看 Caddy 的服务日志:
journalctl -u caddy --no-pager -n 100核心报错:
error":"performing request: Get "https://acme-v02.api.letsencrypt.org/directory": dial tcp: lookup acme-v02.api.letsencrypt.org: i/o timeout"
-
分析报错 lookup … i/o timeout 说明是 DNS 解析超时。
-
验证网络连通性 尝试在服务器上手动解析域名,排查是否为系统级 DNS 问题:
nslookup acme-v02.api.letsencrypt.org结果:;; connection timed out; no servers could be reached
现象:服务器完全无法连接到 DNS 服务器进行查询。
- 根因定位 (Root Cause) 网络拓扑:该服务器位于“内网中的内网”(Nested LAN / Separate VLAN),网关为 OPNsense。
原因:检查 OPNsense 防火墙规则,发现针对该子网 缺少 Port 53 (DNS) 的 Pass 规则。
后果:导致该网段内的机器无法访问上游(内网)DNS 服务器,从而无法解析 Let’s Encrypt 的域名。
Solution
登录 OPNsense。
在对应的 Interface/VLAN 防火墙规则中,添加 Pass 规则:
Protocol: TCP/UDP
Dest. Port: 53 (DNS)
应用更改后,nslookup 恢复正常。
重启 Caddy,证书成功更新。
systemctl restart caddy