Route 53 Record Set on Different Port

27,735

Solution 1

This is possible through S3 redirection. Create a S3 bucket with the name

subdomain.domain.com

This bucket does not need to be public. Then, turn on Static Website Hosting in Properties and choose the Redirect response option and configure it with the following options

Target bucket or domain: my.ip:8000
Protocol: Leave this blank

Then go to Route53 and create a Record Set with the following configuration

  • Name: subdomain.domain.com
  • Type: A-IPv4 address
  • Alias: Yes
  • Alias Target: Choose the bucket you just created in S3. If it does not appear wait for it to appear.
  • Routing Policy: Simple
  • Evaluate Target Health: No

And that's it, you should be able to go to subdomain.domain.com and see the changes take effect after roughly 30 seconds. Best of luck!

Solution 2

In general, DNS does not care about ports.

You should be able to however, configure nginx to handle both virtual hosts with a reverse proxy to the node.js app. All requests would hit port 80, but how they get handled would depend on the domain.

Solution 3

I followed the idea from datasage's answer, and this is how I done it!

On Route 53:

  1. Go to the hosted zone of your domain, click "Create records"
  2. Enter your subdomain under Record name. For example if you want to create "sub.mywebsite.com", type in "sub"
  3. Select CNAME as Record type.
  4. Enter your domain under "Value". For example "mywebsite.com"
  5. Choose a TTL value that is suitable for your use case.
  6. Choose "Simple Routing"
  7. Click "Create records"

And then, create virtual host on your Nginx server:

server {
  server_name sub.mywebsite.com;
  location / {
    proxy_pass http://localhost:xxxx;
  }
}

In fact, you can create as many as you want!

server {
  server_name sub1.mywebsite.com;
  location / {
    proxy_pass http://localhost:xxxx;
  }
}
server {
  server_name sub2.mywebsite.com;
  location / {
    proxy_pass http://localhost:xxxx;
  }
}

And that's it!

Share:
27,735
gverri
Author by

gverri

Updated on July 09, 2022

Comments

  • gverri
    gverri almost 2 years

    I'm a ruby dev and I just started to learn some Node.js.

    I'm running an instance on AWS to host my rails apps with passenger + nginx listening on port 80.

    Now I would like to host a node.js app on the same instance (t1-micro) and put it to listen on port 8000.

    How can I use Route 53 to create a Record Set to point a subdomain.domain.com to my.ip:8000?

    I already tried setting an IPV4 record pointing to my.ip:8000 with no success.

    Any idea what I'm doing wrong?

    Can I use nginx to serve my nodejs apps?