# OAuth2 和 Letsencrypt 冲突

**URL:** https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536
**Category:** Support
**Tags:** oauth2, letsencrypt
**Created:** [2026年一月28日 13:07 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536 "2026-01-28T13:07:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Ostap1974](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ostap1974/32/493443_2.png) [@Ostap1974](https://meta.discourse.org/u/Ostap1974)
#### Post date: [2026年一月28日 13:07 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/1 "2026-01-28T13:07:01Z")

</div>

我有一个在 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](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](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](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 个月的问题，但我希望彻底解决它。有什么建议吗？

提前感谢。

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [2026年一月28日 13:19 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/2 "2026-01-28T13:19:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Ostap1974](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ostap1974/32/493443_2.png) [@Ostap1974](https://meta.discourse.org/u/Ostap1974)
#### Post date: [2026年一月28日 14:32 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/3 "2026-01-28T14:32:35Z")

</div>

更多关于此问题的信息：  
我可以看到传入的 acme-challenge 请求到 [http://community.site/.well-known/…](http://community.site/.well-known/%E2%80%A6)  
它被重定向到 **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](https://community.site)。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年一月28日 14:37 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/4 "2026-01-28T14:37:27Z")

</div>

> [@Ostap1974](#):
>
> 我找到了一个 `/etc/nginx/conf.d/outlets/before-server/20-redirect-http-to-https.conf` 文件，它似乎总是对端口 80 的任何请求返回 301 [https://community.site](https://community.site)。

该问题已于去年八月修复，[letsencrypt updates: renew location for .well-known, add support for … · discourse/discourse\_docker@ae4887a · GitHub](https://github.com/discourse/discourse_docker/commit/ae4887a4f716b68f53f547f603be3b834a2b0c78)

---

<div class="post-metadata">

### Author: ![Ostap1974](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ostap1974/32/493443_2.png) [@Ostap1974](https://meta.discourse.org/u/Ostap1974)
#### Post date: [2026年一月28日 15:40 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/5 "2026-01-28T15:40:45Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年一月28日 15:52 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/6 "2026-01-28T15:52:26Z")

</div>

啊，我看到还有更多内容，你可以[在这里读到该主题的结尾](https://meta.discourse.org/t/discourse-failure-to-renew-certificate/385148/10)，然后你会看到12月22日还有[另一个](https://github.com/discourse/discourse_docker/commit/ebead81303078da7905e9656e2829b2dcf89ffe6)修复。所以这就解释了为什么你会遇到它。

---

<div class="post-metadata">

### Author: ![Ostap1974](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ostap1974/32/493443_2.png) [@Ostap1974](https://meta.discourse.org/u/Ostap1974)
#### Post date: [2026年一月28日 15:57 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/7 "2026-01-28T15:57:17Z")

</div>

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

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

应该改为

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

如果我错了，请纠正我。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2026年一月28日 16:01 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/8 "2026-01-28T16:01:43Z")

</div>

这正是我提到的[另一个修复](https://github.com/discourse/discourse_docker/commit/ebead81303078da7905e9656e2829b2dcf89ffe6)所修复的，修复了

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/6/2/462f597ab9afe9e67cff53f7c0b9c9aec4119c4e.png)

---

<div class="post-metadata">

### Author: ![Ostap1974](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ostap1974/32/493443_2.png) [@Ostap1974](https://meta.discourse.org/u/Ostap1974)
#### Post date: [2026年一月28日 16:44 UTC](https://meta.discourse.org/t/oauth2-and-letsencrypt-clash/394536/9 "2026-01-28T16:44:34Z")

</div>

再次感谢，非常有帮助！
