DNS question

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

1 Like

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.

1 Like

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:

1 Like