在仔细检查所有日志后,发现错误出在 Let’s Encrypt 证书颁发上。遇到类似问题的朋友可以参考以下解决方案。
首先,我在 Nginx 日志中看到了这个错误:
cannot load certificate "/shared/ssl/forum.abc.com.au.cer": PEM_read_bio_X509_AUX() failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
然后尝试检查 SSL 日志:
forum.abc.com.au:Verify error:CAA record for forum.abc.com.au prevents issuance
在为子域名运行 Discourse 安装脚本之前,我们需要确认主域名是否包含任何 CAA 记录,并检查证书颁发机构(CA)是否不是 Let’s Encrypt(在我的案例中,主域名的 CAA 记录指向 comodoca.com)。如果主域名的 CAA 记录限制了证书颁发机构,那么您的 Discourse 子域名将无法获得 Let’s Encrypt 证书。
修复方法:您需要为 Discourse 子域名添加 CAA 记录,具体步骤请参考以下链接
Acme:error:caa :: CAA record for ... prevents issuance - Help - Let's Encrypt Community Support
删除旧的证书文件并重新构建:
rm -rf /var/discourse/shared/standalone/ssl
rm -rf /var/discourse/shared/standalone/letsencrypt
./launcher rebuild app