# DNS question

**URL:** https://meta.discourse.org/t/dns-question/266235
**Category:** Self-hosting
**Created:** [May 25, 2023, 5:00pm UTC](https://meta.discourse.org/t/dns-question/266235 "2023-05-25T17:00:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![agf1997](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@agf1997](https://meta.discourse.org/u/agf1997)
#### Post date: [May 25, 2023, 5:00pm UTC](https://meta.discourse.org/t/dns-question/266235/1 "2023-05-25T17:00:53Z")

</div>

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](http://community.example.com))

However, I’d like to have the root domain (e.g. [example.com](http://example.com)) forward the user to the subdomain (e.g. [community.example.com](http://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.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [May 25, 2023, 5:12pm UTC](https://meta.discourse.org/t/dns-question/266235/2 "2023-05-25T17:12:36Z")

</div>

> [@agf1997](#):
>
> 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.

It’s correct; this would break DNS.

A [provider that supports CNAME flattening](https://meta.discourse.org/t/configure-your-hosted-discourse-site-to-run-at-the-root-or-apex-domain-e-g-example-com/60951) (essentially, doing the A/AAAA records automatically) would make this work though.

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

---

<div class="post-metadata">

### Author: ![agf1997](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@agf1997](https://meta.discourse.org/u/agf1997)
#### Post date: [May 25, 2023, 6:32pm UTC](https://meta.discourse.org/t/dns-question/266235/3 "2023-05-25T18:32:42Z")

</div>

> [@supermathie](#):
>
> 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](http://example.com)? Sorry just trying to get this straight in my brain

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [May 25, 2023, 6:35pm UTC](https://meta.discourse.org/t/dns-question/266235/4 "2023-05-25T18:35:27Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)
#### Post date: [May 26, 2023, 6:20pm UTC](https://meta.discourse.org/t/dns-question/266235/5 "2023-05-26T18:20:44Z")

</div>

> [@agf1997](#):
>
> 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.

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](https://docs.gandi.net/en/domain_names/common_operations/web_forwarding.html)”.

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