jamierobinson set up a Discourse community on Digital Ocean with a naked domain (https://example.com) and wanted to add www. to the URL. Initially confused about DNS settings, they had an A record for the naked domain and a CNAME for www., but this didn’t consistently show www. in the browser. itsbhanusharma suggested using a CNAME record for www pointing to @ and following a guide to change the domain. After re-running the discourse-setup script, the www version worked, but the naked domain stopped functioning jamierobinson. pfaffman recommended forcewww.com or setting up Let’s Encrypt for multiple domains. jamierobinson considered a simple 301 redirect, which JammyDodger explained forcewww.com does automatically while provisioning Let’s Encrypt certs. jamierobinson confirmed the plan: point the naked domain’s A record to forcewww’s IP and www to their server IP — replacing CNAMEs with A records. After setup, it took time to propagate, but eventually worked jamierobinson. However, email via Mailgun broke jamierobinson. pfaffman advised updating the DISCOURSE_NOTIFICATION_EMAIL to use the bare domain and rebuilding the container. jamierobinson resolved it by resetting the SMTP password and re-running the setup script — unsure why, but it worked.
I have set up my Discourse community with Digital Ocean, but the domain name is “naked”, at just https://example.com. I would like to add the www., but not quite sure what I am doing when it comes to DNS settings!
At the moment I have an ‘A’ record pointing to the IP and a ‘CNAME’ record with www. pointing to this. Is it as simple as changing the www. to an ‘A’ record and ditching the CNAME? Or perhaps I have them both as ‘A’ records? Or perhaps there is a simple setting in Discourse itself which selects how the domain will appear?
It is funny, I have a normal wix site which appears to be the same configuration with a naked A record and www. CNAME which shows up as www. in the browser - so I am not sure what it is that makes it show like that.
I promise I have tried to further educate myself on DNS, but am totally confused!
Any help on how to add the www. is much appreciated!
Thank you very much for this - I have successfully got it working at the www. by re-running the discourse-setup script as in your article, but now the naked domain no longer works! Is there any way I can make the naked domain work as well - or at least automatically fill in the www.?
So I now have A record linking naked domain to IP address
CNAME record linking www to naked domain
Thank you for this - I have read through both options, but just wondered, why could I not just use a simple 301 redirect to redirect from naked domain to www.? Is this worth a try or am I breaking DNS laws?
Both of those methods provide a letsencrypt certificate for the second (sub)domain. Adding the extra info to your app.yml covers both domain addresses in the same certificate, and forcewww.com has some special magic that does it on the fly so you don’t have to worry about it:
O.K sounds as if I should just use forcewww. Can I just confirm (sorry I am very out of my depth) - they are asking me to set up the www as an A record to my server IP, and the naked domain as an A record to the IP address they give? So no CNAMES?
What I have now:
A record pointing naked domain to server IP
CNAME record pointing www to naked domain
Proposed change using ForceWWW
A record pointing naked domain to forcewww IP
A record pointing www to my server IP
Unfortunately - this has somehow broken the emailing system - the site is not sending any emails through mailgun. Might this be because of the forcewww - as the host is now through their server? Or do I need to update mailgun to say www? Lord give me strength.
Thanks - I reset the smtp password and then ran the discourse setup script again and that seems to have done the job! I don’t know how or why, but it works so I will just not touch anything!