# 多次重建后 SSL 出现问题

**URL:** <https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637>\
**Category:** Support\
**Created:** [2020年一月24日 11:22 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637 "2020-01-24T11:22:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月24日 11:22 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/1 "2020-01-24T11:22:02Z")

</div>

连续第三个帖子了……因为当我编辑时，我以为新回复里不会显示出来。

我已经按照你们说的做了所有步骤。我已经导入了所有内容，导入器已停止，应用也已启动。但仍然无法连接到我的网站 ☹

Firefox 提示：嗯，我们找不到该网站。无法连接到 [我的 Discourse 站点] 的服务器

……双手合十，希望能有人知道答案

---

<div class="post-metadata">

**Author:** ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)\
**Post date:** [2020年一月24日 11:40 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/2 "2020-01-24T11:40:01Z")

</div>

信息太少，很难给出确切答案。我们目前只知道您的网站无法访问。

- 您检查过日志吗？日志显示了什么？
- 启动应用后，您是否多等待了几分钟？网站可能需要一段时间才能变得可访问。

鉴于此处与您情况相关的帖子数量较多，建议将它们拆分到一个单独的主题中，因为这似乎只与导入器部分相关。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月24日 11:58 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/3 "2020-01-24T11:58:06Z")

</div>

你好，Helmi，谢谢你的回复。是的，我同意这可能属于另一个话题，但由于问题是在我导入时开始的，所以我先把它放在这里。

关于你的问题，我是在 DigitalOcean 的 Droplet 上自行安装的 Discourse。一切原本运行正常，导入也已完成。但因为我忘记设置表情符号的路径，所以不得不重新进行完整的导入。为此，我删除了所有内容。然而，从那时起，问题就开始出现了。

我曾在导入前成功连接到论坛，恢复了所有设置（包括主题等）的备份。随后，由于我在表情符号的路径设置上犯了错误，不得不中止导入，因此必须从头再来。于是，我再次删除所有内容，然后重新导入（我是这么认为的）。

但自那以后，我无法再连接到网站了。Discourse Doctor 检查后显示一切正常，只是找不到我的 Discourse 版本。关于日志，请告知查看日志的命令，我可以去检查。是的，我已经等了又等，再等……但仍然无法连接。

我真的不知道应该从哪里着手解决这个问题。如果你有任何建议，请告诉我 🙂

编辑：所以我找到了查看日志的方法……日志中充满了 SSL 错误。因此，我现在正尝试使用以下链接重新安装新的证书：[https://meta.discourse.org/t/setting-up-https-support-with-lets-encrypt/40709。我真心希望这能解决问题。](https://meta.discourse.org/t/setting-up-https-support-with-lets-encrypt/40709%E3%80%82%E6%88%91%E7%9C%9F%E5%BF%83%E5%B8%8C%E6%9C%9B%E8%BF%99%E8%83%BD%E8%A7%A3%E5%86%B3%E9%97%AE%E9%A2%98%E3%80%82)

---

<div class="post-metadata">

**Author:** ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)\
**Post date:** [2020年一月24日 12:39 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/4 "2020-01-24T12:39:33Z")

</div>

SSL 错误通常意味着您已经过于频繁地请求了 Let’s Encrypt 证书。您的域名可能暂时被 Let’s Encrypt 屏蔽。请仔细检查，如果是这种情况，可以暂时使用子域名来绕过此限制。

至于其他方面：既然您使用的是 DigitalOcean，建议未来每次完成一个希望随时回退的步骤时，都在 DigitalOcean 上创建一次快照，以便在出现问题时能够恢复。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月24日 12:47 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/5 "2020-01-24T12:47:54Z")

</div>

非常感谢你关于快照的提示。我下次一定会记住这一点！

另外，我已经通过从备份中复制回 SSL 目录解决了问题。原来不知为何证书变成了 0KB 的文件？真奇怪。当我把旧文件放回去后，就能正常访问了。

感谢大家的帮助和支持。我想我现在之前的帖子更适合归类到支持/SSL 相关板块（当然，我当时发帖时并不知道这一点）。

编辑：更新，在重新构建应用后，SSL 似乎每次都会被删除。这是否意味着每次重建时都会请求一个 Let’s Encrypt 证书？如果是的话，我理解系统可能会认为我请求过于频繁……我为了找出问题所在，已经重建了很多次。

---

<div class="post-metadata">

**Author:** ![Remah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/remah/32/70590_2.png) [@Remah](https://meta.discourse.org/u/Remah)\
**Post date:** [2020年一月24日 13:59 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/6 "2020-01-24T13:59:34Z")

</div>

> [@Queth](#):
>
> 每次重建时都会请求 LE 证书吗？

不会。据我所知，它会检查证书的到期日期，并在需要时进行续期。

显然，您可以在七天内获取五个证书：

> [@Cloudflare with Discourse](https://meta.discourse.org/t/cloudflare-with-discourse/137456/41?u=remah):
>
> There’s no reason you’d need a different IP. There may be other problems, but this will be a definite blocker. …which is your problem. Let’s Encrypt will only issue five certs for a given set of FQDNs within a week. You exhausted that limit within 45 minutes. Once you did that, any further attempt at installation was guaranteed to fail.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年一月24日 14:57 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/7 "2020-01-24T14:57:05Z")

</div>

其中一条错误提示似乎表明您的域名未指向正确的 IP 地址。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月24日 15:36 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/8 "2020-01-24T15:36:07Z")

</div>

感谢 JahDu，那么重建后 SSL 密钥未正确设置就更奇怪了。

@Jay，这确实很奇怪，因为之前一切正常，IP 地址和其他配置都相同。域名已指向正确的 IP。

Discourse 位于我主域名的子域名下，两者运行在不同的服务器上，子域名的 IP 与主域名不同。但子域名已正确配置在 SSL 设置中。

我本打算再检查一遍 app.yml，但系统正在重新处理 10 万篇帖子（为了让某个插件正常工作），这需要一些时间……

编辑：已再次检查 app.yml，自一切正常以来没有任何更改。  
现在我该从哪里着手排查？

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月25日 19:01 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/9 "2020-01-25T19:01:39Z")

</div>

我刚刚又进行了一次重新导入。这次没有重建应用。我先恢复了备份，然后导入了 phpBB3 数据库。导入后，SSL 密钥再次出错。我并没有重建任何东西，只是启动并停止了 app.yml 和 import.yml 容器。

我束手无策。通过管理控制面板恢复备份会导致 SSL 出问题吗？我在导入之后才检查 SSL 目录，所以不知道问题具体是什么时候发生的。

谁能帮我解开这个谜团？

---

<div class="post-metadata">

**Author:** ![helmi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/helmi/32/114772_2.png) [@helmi](https://meta.discourse.org/u/helmi)\
**Post date:** [2020年一月25日 20:33 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/10 "2020-01-25T20:33:27Z")

</div>

关于 SSL 故障有任何细节吗？比如来自日志的？我仍然假设是 Let’s Encrypt 阻止了你的域名，但如果没有日志中的详细信息，很难确定。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月27日 11:05 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/11 "2020-01-27T11:05:40Z")

</div>

问题在于，SSL 目录中的文件会被某种方式覆盖，导致 .key 和/或 .cer 文件大小变为 0KB，而不是应有的 3KB 左右。通常只有一两个文件被“损坏”为 0KB，并非全部。我目前的解决方法是将备份文件复制回去，但这只是一个临时方案。

在修复这些文件之前，日志中会反复出现以下错误：

> nginx: [emerg] cannot load certificate “/shared/ssl/[mydomain]\_ecc.cer”: BIO\_new\_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(‘/shared/ssl/[domain]\_ecc.cer’,‘r’) error:2006D080:BIO routines:BIO\_new\_file:no such file)  
> nginx: [emerg] cannot load certificate “/shared/ssl/[domain]\_ecc.cer”: PEM\_read\_bio\_X509\_AUX() failed (SSL: error:0909006C:PEM routines:get\_name:no start line:Expecting: TRUSTED CERTIFICATE)

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2020年一月27日 11:26 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/12 "2020-01-27T11:26:23Z")

</div>

请查看容器内的 `/shared/letsencrypt/acme.sh.log` 文件，以了解具体情况。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月27日 11:46 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/13 "2020-01-27T11:46:55Z")

</div>

啊，我都不知道那里也有日志 🙂 谢谢你指出这一点！

那边发生了很多事，看起来每次重建时都在更新证书？因为有很多“更新”相关的操作。而且 @helmi 说得对，我想你指的是这个：

> [Sat 25 Jan 2020 06:48:31 PM UTC] Create new order error. Le\_OrderFinalize not found. {  
> “type”: “urn:ietf:params:acme:error:rateLimited”,  
> “detail”: "Error creating new order :: too many certificates already issued for exact set of domains: $  
> “status”: 429

所以……我该怎么绕过这个限制呢？

编辑：根据 Let’s Encrypt 的说法：

> 如果你触发了速率限制，我们无法临时重置它。你需要等待一周，直到速率限制过期。

然后我找到了 [Rate Limits - Let's Encrypt](https://letsencrypt.org/docs/rate-limits/)

所以……我想我只得等一周了……

编辑2：我查了 [https://crt.sh/，过去一周我只看到](https://crt.sh/%EF%BC%8C%E8%BF%87%E5%8E%BB%E4%B8%80%E5%91%A8%E6%88%91%E5%8F%AA%E7%9C%8B%E5%88%B0) 10 个证书？不是 50 个……

问题：它什么时候把证书视为更新？我想只有在我重新构建应用时才会这样吧？

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年一月27日 13:45 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/14 "2020-01-27T13:45:50Z")

</div>

您是否使用了大小写混合的主机名？我原以为代码现在会自动转换为小写，但这只是我的猜测。我相当确定，如果证书仍然有效，重建通常不会请求新证书。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月27日 17:58 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/15 "2020-01-27T17:58:28Z")

</div>

你的意思是 app.yml 中 DISCOURSE\_HOSTNAME 所定义的内容吗？  
不，那里全是小写。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年一月27日 21:13 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/16 "2020-01-27T21:13:56Z")

</div>

据我所知，只有当您的证书请求因某种原因失败时，才会达到该限制。

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年一月27日 21:57 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/17 "2020-01-27T21:57:50Z")

</div>

谢谢 🙂 我该如何/在哪里检查它们是否失败？你知道我在日志中应该查找什么错误吗？

---

<div class="post-metadata">

**Author:** ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)\
**Post date:** [2020年一月27日 23:39 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/18 "2020-01-27T23:39:56Z")

</div>

如果您前往 Let’s Encrypt 论坛，在“帮助”类别下创建新主题，并填写您看到的表单，他们就可以检查您的域名，并告知您是否存在任何问题（如有）。他们还可以帮助您修复任何问题。  
顺便提一下：Let’s Encrypt 建议使用“测试（staging）”模式，以避免触发生产模式下遇到的证书限制。5 次失败尝试的限制会在 1 小时后重置。😉

---

<div class="post-metadata">

**Author:** ![Queth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/queth/32/154753_2.png) [@Queth](https://meta.discourse.org/u/Queth)\
**Post date:** [2020年二月1日 14:40 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/19 "2020-02-01T14:40:09Z")

</div>

谢谢 Jim，等错误再次出现时我会那样做。  
我刚刚又进行了一次重建，果然没有 SSL 错误！

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2020年三月2日 14:54 UTC](https://meta.discourse.org/t/trouble-with-ssl-after-lots-of-rebuilds/139637/20 "2020-03-02T14:54:37Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
