# 自定义nginx时出现SSL错误：证书在所有浏览器中不受信任

**URL:** https://meta.discourse.org/t/ssl-error-when-customizing-nginx-the-certificate-is-not-trusted-in-all-web-browsers/203164
**Category:** Self-hosting
**Created:** [2021年九月10日 14:14 UTC](https://meta.discourse.org/t/ssl-error-when-customizing-nginx-the-certificate-is-not-trusted-in-all-web-browsers/203164 "2021-09-10T14:14:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bcat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bcat/32/163148_2.png) [@Bcat](https://meta.discourse.org/u/Bcat)
#### Post date: [2021年九月10日 14:14 UTC](https://meta.discourse.org/t/ssl-error-when-customizing-nginx-the-certificate-is-not-trusted-in-all-web-browsers/203164/1 "2021-09-10T14:14:09Z")

</div>

**我修改了一些设置，以便在同一台 Discourse 服务器上承载其他工作。**

某些浏览器在访问网站时会显示 SSL 通知（白屏）：

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/a/3a1d02279120716ea58ff47e8c987c97812670f2.jpeg)

**文件：** `/var/discourse/containers/app.yml`

```plaintext
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## 如果您想添加 Let's Encrypt (https)，请取消注释以下两行
  # - "templates/web.ssl.template.yml"
  # - "templates/web.letsencrypt.ssl.template.yml"
  - "templates/web.socketed.template.yml"

```

自动 SSL 生成功能不会像上述那样在更改时运行，因此我手动执行如下操作：

```plaintext
cd /var/discourse
./launcher enter app
"/shared/letsencrypt"/acme.sh --cron --home "/shared/letsencrypt" --force
exit

```

然后执行 `systemctl restart nginx`

这是我的 nginx 配置：

```plaintext
server {
    listen 443 ssl http2;

    ssl on;

    ssl_certificate /var/discourse/shared/standalone/letsencrypt/thuvienmuasam.com/thuvienmuasam.com.cer;
    ssl_certificate_key /var/discourse/shared/standalone/letsencrypt/thuvienmuasam.com/thuvienmuasam.com.key;

```

上次没问题，但这次出现了上述错误。

请告诉我，我这样做对吗？

---

<div class="post-metadata">

### Author: ![Bcat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bcat/32/163148_2.png) [@Bcat](https://meta.discourse.org/u/Bcat)
#### Post date: [2021年九月12日 02:58 UTC](https://meta.discourse.org/t/ssl-error-when-customizing-nginx-the-certificate-is-not-trusted-in-all-web-browsers/203164/2 "2021-09-12T02:58:15Z")

</div>

我知道这个问题大约是在 6 个月前提出的。因此，如果您仍在寻找解决方案，不妨尝试以下方法：

- 复制 ca-bundle 内容（证书），并将其粘贴到您的域名证书之后，放在**证书 (CRT) 字段**中。

是的，这意味着您的 CRT 字段中会有两个证书（域名证书和 ca-bundle 证书），示例如下：

**证书 (CRT)**

```plaintext
-----BEGIN CERTIFICATE-----

(域名证书)

-----END CERTIFICATE-----

-----BEGIN CERTIFICATE-----

(ca-bundle 证书)

-----END CERTIFICATE-----

```

文件路径：`/var/discourse/shared/standalone/letsencrypt/thuvienmuasam.com`

如果此方法有效，那只是说明您的托管提供商安装证书的方式如此。

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/1/a1a49edfb68dff08090a51823462b0f8898670fb.jpeg)

---

<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: [2021年十月12日 02:58 UTC](https://meta.discourse.org/t/ssl-error-when-customizing-nginx-the-certificate-is-not-trusted-in-all-web-browsers/203164/3 "2021-10-12T02:58:53Z")

</div>

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