OAuth2 和 Letsencrypt 冲突

我有一个在 Ubuntu 上运行的 Discourse Docker 容器(从 DO 模板创建),启用了“自定义 OAuth2”。它运行得非常好,除了它无法更新其 Letsencrypt 证书。

在追踪问题时,我从日志中看到更新脚本由 Cron 执行,但由于 Discourse 将挑战回调重定向到 OAuth2 IDP,因此挑战被拒绝。

这是(已编辑的)日志:
[Wed Jan 28 12:40:32 PM UTC 2026] Renewing: ‘community.site’
[Wed Jan 28 12:40:32 PM UTC 2026] Renewing using Le_API=https://acme-v02.api.letsencrypt.org/directory
[Wed Jan 28 12:40:33 PM UTC 2026] Using CA: https://acme-v02.api.letsencrypt.org/directory
[Wed Jan 28 12:40:33 PM UTC 2026] Single domain=‘community.site’
[Wed Jan 28 12:40:35 PM UTC 2026] Getting webroot for domain=‘community.site’
[Wed Jan 28 12:40:35 PM UTC 2026] Verifying: community.site
[Wed Jan 28 12:40:36 PM UTC 2026] Pending. The CA is processing your order, please wait. (1/30)
[Wed Jan 28 12:40:40 PM UTC 2026] community.site: Invalid status. Verification error details: 1.2.3.4: Invalid response from https://oauth.site/authorize?client_id=xxx
[Wed Jan 28 12:40:40 PM UTC 2026] Please check log file for more details: /shared/letsencrypt/acme.sh.log
[Wed Jan 28 12:40:40 PM UTC 2026] Error renewing community.site.

重建应用可以解决接下来的 3 个月的问题,但我希望彻底解决它。有什么建议吗?

提前感谢。

我不太确定这里有什么明显的问题,但老实说,我会把设置放在反向代理后面,在那里终止 SSL,然后改用 DNS 验证。(这只是一个变通方法,而不是解决方案,因为问题未知)

更多关于此问题的信息:
我可以看到传入的 acme-challenge 请求到 http://community.site/.well-known/…
它被重定向到 https://community.site/,然后重定向到 /oauth_basic。第二次重定向是完全预期的,但第一次不是。
传入的 challenge 请求出现在 access.log 中,access.letsencypt.log 是空的

我发现了一个 /etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf 文件,它似乎总是对任何端口 80 的请求返回 301 https://community.site

该问题已于去年八月修复,letsencrypt updates: renew location for .well-known, add support for … · discourse/discourse_docker@ae4887a · GitHub

2 个赞

有趣的是,我在 11 月 26 日重建了应用程序,所以我想修复程序应该在那时已经包含进去了……

无论如何,感谢大家的帮助。让我们关闭这个话题,并希望在下一次重建后问题不会再出现。

啊,我看到还有更多内容,你可以在这里读到该主题的结尾,然后你会看到12月22日还有另一个修复。所以这就解释了为什么你会遇到它。

2 个赞

查看了提交记录,我已经安装了。但我认为那里有一个错误。

return 301 https://${DISCOURSE_HOSTNAME}$request_uri;

应该改为

return 301 https://${DISCOURSE_HOSTNAME}\\$request_uri;

如果我错了,请纠正我。

这正是我提到的另一个修复所修复的,修复了

2 个赞

再次感谢,非常有帮助!

1 个赞