2

Using Amazon AWS, I have two Elastic Beanstalk environments. One hosts my React client, and the other hosts a Node.js API for the client.

I own some-domain-name.com and I would like to use two sub-domains:

  • app.some-domain-name.com
  • api.some-domain-name.com

I would like app.some-domain-name.com to point to the React environment, and api.some-domain-name.com to point to the API environment.

Is there a great way to do this using Route 53 and hosted zones? In the past, I've rerouted traffic on different sub-domains to different ports on the same server. I have not, however, been able to route requests to different servers depending on the sub-domain. Thanks!

Andrew D
  • 25
  • 5

2 Answers2

1

Just create 2 CNAME records in whatever DNS host you are using, one for each subdomain. This is the most basic way of using DNS, so any DNS host will support this, no need for Route53 unless you are already using it.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Hey Mark, thanks for the response. The way I understand it, a CNAME will not actually point to a different server, but instead instead direct the request with the subdomain as an alternative path for some domain. i.e `www.some-domain-name.com`, `api.some-domain-name.com` would both redirect to the server pointed at `some-domain-name.com` – Andrew D Feb 11 '19 at 20:07
  • @Andrew I think you understand wrong, but I don't even understand what your comment is saying. You should never be pointing directly to a server/IP address with Elastic Beanstalk, you should always be using the DNS endpoint Elastic Beanstalk provides. You have 2 DNS endpoints already, one for each of your Elastic Beanstalk environments. Now you need to create 2 CNAME records, that point to the two elastic beanstalk DNS endpoints. `app` would point to the React app, and `api` would point to the NodeJS environment. If you are using Route53 you could use `A` records of type `alias` instead. – Mark B Feb 11 '19 at 20:12
0

Actually yes, there is a great / easy way to do it:

Route 53 Dashboard > Hosted zones > your domain > Create record > Define simple record:

enter image description here

You are good to go after you enter your subdomain and choose the environment.

I'm actively using this configuration.

Adem Tepe
  • 564
  • 5
  • 10