Discourse托管在WWW子域名时应设置哪些正确的DNS记录?

你好

我已在 Digital Ocean 的 Droplet 上使用一键安装脚本部署了 Discourse。我将主机名设置为 www.mydomain.com,并选择通过 Let’s Encrypt 签发 SSL 证书。

我的域名托管在 Namecheap,并已设置以下 DNS 记录:

A 记录    WWW   my_droplet_ip_address
A 记录    @         my_droplet_ip_address
CNAME     @         www.mydomain.com

我认为所有设置都是正确的,在我的桌面电脑和笔记本电脑上,我可以通过以下每个 URL 成功访问网站(所有 URL 都会重定向到 https://www.mydomain.com):

https://www.mydomain.com
https://mydomain.com
http://www.mydomain.com
http://mydomain.com

然而,在我的 Android 手机上,使用以下 URL 访问网站时会出现 NET::ERR_CERT_COMMON_NAME_INVALID 警告:

http://mydomain.com
https://mydomain.com

我认为我的设备可能缓存了旧的证书,因为我在本论坛上读到使用裸域名(naked domain)并不推荐,因此我将 Discourse 从裸域名迁移到了 WWW 子域名。不过,清除缓存/数据似乎并未解决问题,因此我想请教一下,我当前的 DNS 设置是否有明显错误?

提前非常感谢。

1 个赞

Discourse generated a certificate only for the www address. If you agree the apex domain via http you get redirected as you expect, but if you access it with https, you get an error.

There are some topics about how to generate a cert for both domains. You might see forcewww.com. That’s easier.

2 个赞

Thanks for your reply. I assume you are referring to this topic?

The issue I had with following this was I don’t appear to have a /etc/nginx directory on my Digital Ocean instance. Do I need to install Nginx manually?

Alternatively, if I were to reinstall Discourse on the naked domain (without the www), would that solve this problem or would I just face the same issue if users were to access it via https://www. ?

Apologies if I’m asking obvious/beginner questions, this area of computing isn’t what I’m familiar with.

1 个赞