DNS question

AI-generated summary

The discussion revolves around setting up a Discourse server on a subdomain (community.example.com) and forwarding the root domain (example.com) to the subdomain.

Initially, agf1997 considered creating a CNAME record to point the root to the subdomain, but this was not possible with their provider, Digital Ocean. supermathie explained that this approach would break DNS and recommended using a provider that supports CNAME flattening or configuring a web server to send a redirect from the root to the subdomain.

agf1997 sought clarification on the setup, and supermathie emphasized that CNAME records are just pointers and don’t affect the browser’s behavior. A web server redirect is still necessary.

maiki shared their experience with a similar setup and highlighted the importance of testing redirects with both HTTP and HTTPS protocols to avoid issues with SSL certificates. They recommended using a redirect service that provisions an SSL certificate, such as Gandi’s “web forwarding” feature.

Sorry for the basic DNS question. I know this isn’t specifically a discourse thing, just trying to figure out the best way to handle this with discourse in the mix.

I want to setup a discourse server on a subdomain (eg. community.example.com)

However, I’d like to have the root domain (e.g. example.com) forward the user to the subdomain (e.g. community.example.com).

I’d like to do this to effectively reserve the root for the future use of another service (say a webserver), but not require users to type in the subdomain to get to the discourse server for now.

Is the best way to setup two A records (one for the root and one for the subdomain) that both point to the discourse server?

I was initially thinking that I should setup a CNAME that points from the root to the subdomain, but digital ocean doesn’t seem to let me do that.

Thanks in advance, and again, sorry for the basic question.

It’s correct; this would break DNS.

A provider that supports CNAME flattening (essentially, doing the A/AAAA records automatically) would make this work though.

Or, you can CNAME your community hostname to the apex domain name.

So the A record for example.com would point to the IP of the discourse server and the CNAME would have community.example.com be an alias of example.com?

Wouldn’t that put the discourse server at example.com? Sorry just trying to get this straight in my brain

For your purposes, the CNAME records are just a pointer in the DNS lookup. The browser doesn’t follow CNAME redirections.

In either case, you would need to configure a web server for example.com to send a redirect to community.example.com.

I’ve done this a bunch in the past, and one “gotcha” I always run into is http://example.org → https://discourse.example.org.

Depending on the redirect, it can lead to messages in the browser saying it is trying to connect to an insecure website.

To get around this I use a redirect service that provisions an SSL cert for the redirect, via my registrar at Gandi. They call it “web forwarding”.

Make sure to test your redirect using different protocols (HTTP and HTTPS) to see how it works for your site visitors. :slight_smile: