My problem is similar to SSL working on root, but not on www
I am not getting whole point. In my case, DNS record is also fine. I followed the step by step instruction, I believe it should work, but it’s not working.
Your topic & the topic you mentioned seem unrelated as discourse generates a valid certificate for the hostname you specify during install, in the other topic, when they install on www, their cert reports as invalid. I don’t think discourse supports multiple domains for standalone install natively.
@PoojaPatel
Assuming, www is your canonical version for Discourse. But you installed Let’s Encrypt only for apex domain.
Here’s fix…
Re-install Discourse
Install SSL for your www because that is your canonical
Restore Discourse backup
Setup Cloudflare
Go to DNS
Enable its DNS only for www CNAME or A record.
However must enable its DNS as well proxy for apex domain
Choose Flexible SSL
Force HTTPS
EXPECTED: HTTPS version should work fine for redirecting users from non-www to www version. Once I fixed SSL error this problem using this method.
Short version without re-installing SSL at www as per your canonical URL, That I cannot recommend.
(Setup Cloudflare proxy completely over www and non-www)
An easier solution is to run discourse behind a reverse proxy like nginx and setting up the SSL and appropriate redirects from there as enabling cloudflare for discourse brings in a whole lot of problems on it’s own.
This is how the Let’s encrypt template requests the certificate:
Specifically --issue -d $$ENV_DISCOURSE_HOSTNAME meaning that it only issues a request for the hostname given to discourse. In order to get both www and non-www you need to adjust the template to issue more than one -d argument.
Something like as shown here:
(read the replies, some adjustments to the original topic are necessary but I am unable to edit it)
Similar situation here. I installed Discourse on example.com and had a CNAME DNS record for www.example.com.
Now I went to https://check-your-website.server-daten.de and got a bad rating, because the SSL certificate was not valid for www.example.com and also http://www.example.com was forwarding to https://example.com.
Steps I took:
Replace CNAME record for www.example.com by A and AAAA records.
Now, the rating for the site has improved, but one issue remains:
Wrong redirect http ⇒ http
Somewhere there’s 301 redirect http://www.example.com ⇒ http://example.com.
I guess it should be http://www.example.com ⇒ https://www.example.com ⇒ https://example.com
FYI, for anybody referencing this post, the /etc/runit/1.d/letsencrypt file changed a little over a month ago and the replace regex in these for www and non-www won’t work anymore.