在通过HTTP构建Discourse时发生错误

  1. 域名配置完成
  2. 已创建 AWS EC2 实例
  3. 使用 ACM 颁发了证书
  4. 配置了 443 端口并通过 ALB 连接了证书
  5. ALB 将域名流量路由到 80 端口的 EC2 实例

在构建 Discourse 之前,我修改了 app.yml 文件以配置 HTTP 连接:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  ## Uncomment the next line to enable the IPv6 listener
  #- "templates/web.ipv6.template.yml"
  - "templates/web.ratelimited.template.yml"
  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
 #- "443:443" # https

进行更改后,我构建了 Discourse 并检查了配置,但 nginx 仍然因以下错误而请求 SSL 密钥:

[emerg] 7416#7416: cannot load certificate "/shared/ssl/discourse.xxxxxxx.com.cer": PEM_read_bio_X509_AUX() failed (SSL: error:0480006C:PEM routines::no start line:Expecting: TRUSTED CERTIFICATE)

有什么方法可以阻止 nginx 尝试加载密钥,或者让 nginx 通过 HTTP 正常工作吗?

错误发生的原因是 Nginx 仍在查找 SSL 证书,但您的 ALB 正在处理 SSL。解决方法如下:

  1. 检查您的 app.yml 看起来您已经禁用了 SSL 模板,因此可以跳过此步骤。

  2. 重建 Discourse: 运行 ./launcher rebuild app 来应用更改。

  3. 检查 Nginx 设置: 在容器内部,查看 Nginx 配置并确保没有 SSL 行(ssl_certificatessl_certificate_key)。如果找到任何内容,请将其删除并使用 sv restart nginx 重新启动 Nginx。

  4. 验证您的 ALB 设置: 确保您的 ALB 在端口 443 上终止 SSL,并将 HTTP(端口 80)转发到您的 EC2。

这样 Nginx 应该就不会再查找 SSL 证书了,一切都应该可以通过 HTTP 正常工作!

谢谢。我根据相关内容和其他反馈解决了这个问题。