# 自上次更新后，无法安全连接到自托管的 Discourse

**URL:** <https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163>\
**Category:** Self-hosting\
**Created:** [2025年七月28日 11:39 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163 "2025-07-28T11:39:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lubezniy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lubezniy/32/137694_2.png) [@lubezniy](https://meta.discourse.org/u/lubezniy)\
**Post date:** [2025年七月28日 11:39 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/1 "2025-07-28T11:39:27Z")

</div>

您好。几小时前，我使用 `./launcher rebuild app` 更新了 Discourse Image 和 Discourse。在此过程中，我遇到了一些错误，通过从 `app.yml` 中删除已弃用的插件安装行得以修复。没有进行其他配置更改。现在我有一个正在运行的 Docker 容器，监听 80 和 443 TCP 端口，但容器内的 nginx 拒绝接受 SSL/TLS 连接。容器内的 error.log 显示证书没有错误，access.log 显示没有请求，telnet 到 443 端口显示连接被拒绝，TCP 端口 80 上的 HTTP 访问正常，但我们遇到了 SSO 身份验证问题（可能是安全 cookie 问题）。Launcher 重启和 discourse-doctor 均无效。在容器内重启 nginx 也无效。现在应该在哪里查找问题以及该怎么做？

---

<div class="post-metadata">

**Author:** ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)\
**Post date:** [2025年七月28日 11:59 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/2 "2025-07-28T11:59:12Z")

</div>

> [@lubezniy](#):
>
> telnet 到 443 端口显示连接被拒绝

如果启用了 `ufw` 并且未设置为允许 HTTPS 端口 443 上的连接，则会出现这种情况。

* * *

编辑：您需要打开此端口才能使 #mail-receiver 正常工作。

---

<div class="post-metadata">

**Author:** ![lubezniy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lubezniy/32/137694_2.png) [@lubezniy](https://meta.discourse.org/u/lubezniy)\
**Post date:** [2025年七月28日 12:13 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/3 "2025-07-28T12:13:48Z")

</div>

我没有对ufw、iptables等进行任何配置更改。在更新之前端口是正常打开的。配置是否会在Discourse更新过程中被更改？

---

<div class="post-metadata">

**Author:** ![Ethsim2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ethsim2/32/522255_2.png) [@Ethsim2](https://meta.discourse.org/u/Ethsim2)\
**Post date:** [2025年七月28日 12:22 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/4 "2025-07-28T12:22:12Z")

</div>

> [@lubezniy](#):
>
> 可以在 Discourse 更新过程中更改配置吗？

当然可以，Discourse docker 容器应该在 `ufw` 前面。但是，不打开 443 端口会导致不同容器之间的通信问题或 `telnet` 问题。

* * *

`.\launcher logs app` 返回什么？（您可以使用 MS Word 来编辑您的域名等）

您是通过 PuTTy 还是其他 SSH 客户端访问您的服务器？是否打开了 `22` 端口？

---

<div class="post-metadata">

**Author:** ![tanya\_byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tanya_byrne/32/444826_2.png) [@tanya\_byrne](https://meta.discourse.org/u/tanya_byrne)\
**Post date:** [2025年七月28日 17:13 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/5 "2025-07-28T17:13:46Z")

</div>

我也在自托管实例上看到了这个问题，这是在最近重建之后出现的。除了重建本身，配置没有任何变化。我可以通过 SSH 访问服务器，这是 `./launcher logs app` 的输出。

```plaintext

run-parts: executing /etc/runit/1.d/00-ensure-links
run-parts: executing /etc/runit/1.d/00-fix-var-logs
run-parts: executing /etc/runit/1.d/01-cleanup-web-pids
run-parts: executing /etc/runit/1.d/anacron
run-parts: executing /etc/runit/1.d/cleanup-pids
Cleaning stale PID files
run-parts: executing /etc/runit/1.d/copy-env
run-parts: executing /etc/runit/1.d/install-ssl
Started runsvdir, PID is 45
ok: run: redis: (pid 55) 0s
supervisor pid: 53 unicorn pid: 76

```

Docker 容器正在运行，我的 `docker ps` 输出证明了这一点。（容器 ID 已隐藏）

` local_discourse/app “/sbin/boot” 16 minutes ago Up 16 minutes 0.0.0.0:80-\u003e80/tcp, [::]:80-\u003e80/tcp, 0.0.0.0:443-\u003e443/tcp, [::]:443-\u003e443/tcp, 0.0.0.0:5432-\u003e5432/tcp, [::]:5432-\u003e5432/tcp app`

一个重要的注意事项是，我们不使用 openSSL 来获取证书，因为需要一个特定的颁发者。但是，此证书没有更改，并且在重建之前一直正常工作。

看起来 nginx 期望的 IP（本地 IP）与分配给容器的 IP 之间存在不匹配。看起来容器可能在桥接模式下运行？这是容器的网络设置。

```plaintext
“Labels”: {
    “org.opencontainers.image.created”: “2025-07-25T21:40:36+00:00”
},
“NetworkSettings”: {
    “Bridge”: “”,
    “SandboxID”: “[REDACTED]”,
    “SandboxKey”: “[REDACTED]”,
    “Ports”: {
        “443/tcp”: [
            {
                “HostIp”: “0.0.0.0”,
                “HostPort”: “443”
            },
            {
                “HostIp”: “::”,
                “HostPort”: “443”
            }
        ],
        “5432/tcp”: [
            {
                “HostIp”: “0.0.0.0”,
                “HostPort”: “5432”
            },
            {
                “HostIp”: “::”,
                “HostPort”: “5432”
            }
        ],
        “80/tcp”: [
            {
                “HostIp”: “0.0.0.0”,
                “HostPort”: “80”
            },
            {
                “HostIp”: “::”,
                “HostPort”: “80”
            }
        ]
    },
    “HairpinMode”: false,
    “LinkLocalIPv6Address”: “”,
    “LinkLocalIPv6PrefixLen”: 0,
    “SecondaryIPAddresses”: null,
    “SecondaryIPv6Addresses”: null,
    “EndpointID”: “[REDACTED]”,
    “Gateway”: “172.17.0.1”,
    “GlobalIPv6Address”: “”,
    “GlobalIPv6PrefixLen”: 0,
    “IPAddress”: “172.17.0.2”,
    “IPPrefixLen”: 16,
    “IPv6Gateway”: “”,
    “MacAddress”: “[REDACTED]”,
    “Networks”: {
        “bridge”: {
            “IPAMConfig”: null,
            “Links”: null,
            “Aliases”: null,
            “MacAddress”: “[REDACTED]”,
            “DriverOpts”: null,
            “GwPriority”: 0,
            “NetworkID”: “[REDACTED]”,
            “EndpointID”: “[REDACTED]”,
            “Gateway”: “172.17.0.1”,
            “IPAddress”: “172.17.0.2”,
            “IPPrefixLen”: 16,
            “IPv6Gateway”: “”,
            “GlobalIPv6Address”: “”,
            “GlobalIPv6PrefixLen”: 0,
            “DNSNames”: null
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![tanya\_byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tanya_byrne/32/444826_2.png) [@tanya\_byrne](https://meta.discourse.org/u/tanya_byrne)\
**Post date:** [2025年七月28日 18:38 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/6 "2025-07-28T18:38:27Z")

</div>

`app.yml` 中似乎有一个新的 PR 引入了新的变量要求。这似乎还没有文档记录，但您需要在 `app.yml` 文件中添加 `ENABLE_SSL: true`。

---

<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:** [2025年七月28日 22:41 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/7 "2025-07-28T22:41:02Z")

</div>

> [@tanya\_byrne](#):
>
> 这似乎还没有被记录下来，但你需要将 `ENABLE_SSL: true` 添加到你的 `app.yml` 文件中

这听起来像是一个错误。SSL 几年前就已经默认开启了。你能提供一下提交的链接吗？

我在 SSL 模板的代码中看到了它。我可能遗漏了什么，因为我正在用手机查看，而且 GitHub 也有问题，但看起来它会破坏所有自托管的站点。

---

<div class="post-metadata">

**Author:** ![featheredtoast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/featheredtoast/32/116994_2.png) [@featheredtoast](https://meta.discourse.org/u/featheredtoast)\
**Post date:** [2025年七月28日 23:18 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/8 "2025-07-28T23:18:49Z")

</div>

这是这个，绝对是合并 ssl-on-boot 配置时无意中出现的 bug：

> <https://github.com/discourse/discourse_docker/pull/977>
>
> Allows ssl and letsencrypt templates to run on boot via initscripts
> 
> This chan…ge adds the decision to configure https or letsencrypt to be at runtime
> rather than at build time via env vars.
> 
> Under the hood, these are the commands, just migrated to shellscripts
> that run when a container boots.
> 
> Runs on existence of ENABLE\_SSL (base ssl template)
> or LETSENCRYPT\_ACCOUNT\_EMAIL (ssl template+letsencrypt template)
> 
> Both cases checks and errors on blank hostname.

我在这里将 ENABLE\_SSL 默认更新为 1：

> <https://github.com/discourse/discourse_docker/pull/985>
>
> Default ENABLE\_SSL to 1 when template is included.

感谢 @tanya_byrne 的发现。

---

<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:** [2025年七月28日 23:44 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/9 "2025-07-28T23:44:49Z")

</div>

干得漂亮，杰夫！谢谢！

---

<div class="post-metadata">

**Author:** ![tanya\_byrne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tanya_byrne/32/444826_2.png) [@tanya\_byrne](https://meta.discourse.org/u/tanya_byrne)\
**Post date:** [2025年七月29日 00:13 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/10 "2025-07-29T00:13:28Z")

</div>

感谢修复 @featheredtoast

---

<div class="post-metadata">

**Author:** ![lubezniy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lubezniy/32/137694_2.png) [@lubezniy](https://meta.discourse.org/u/lubezniy)\
**Post date:** [2025年七月29日 11:06 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/11 "2025-07-29T11:06:39Z")

</div>

谢谢，各位。我们也解决了这个问题。

---

<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:** [2025年八月28日 11:06 UTC](https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/12 "2025-08-28T11:06:46Z")

</div>

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