-1

My rest API (node) is set up in AWS ECS behind a load balancer - super-long-aws-lb-url

I also have a domain registered and a subdomain for my backend which is set up as an A-record aliased to the load balancer; I access my rest API at something like data.mydomain.com/api/resource/{:id} - this is working as expected.

There's one endpoint that serves as a reverse proxy for accessing user-generated content - it's public and currently I can access it via data.mydomain.com/api/content/public/{:id}

What I'd like to do is create a "pretty" url to just that endpoint in route53 so that the public endpoint becomes available via content.mydomain.com/{:content-id}

So far I've tried setting up this subdomain as a CNAME pointing directly to the string value composed of ALB URL + endpoint

content.mydomain.com -> super-long-aws-lb-url/api/content/public/

I expect that this will allow me to access that content at http://content.mydomain.com/{:content-id} but I get a Server Not Found error

Next I tried setting it up as an A-Record with an alias, but since it needs a resource with an IP address, I'm forced to select an AWS resource from a dropdown, and I'm back to using the load balancer without bypassing the global prefix (api) and the resource URL (content/public)

Is there a way to point a subdomain directly to an API endpoint in AWS?

rakitin
  • 1,943
  • 6
  • 25
  • 51

1 Answers1

1

Amazon Route 53 is a Domain Name Service (DNS).

DNS is used to resolve a domain name (eg data.mydomain.com) to an IP address, which allows traffic to be sent to a specific computer.

DNS only covers the domain name. It does not include anything after the slash.

Therefore, you can not use Amazon Route 53 to point to a 'path' (eg /api/content/public/).

Such redirection would be the job of any software running on the target computer. You can likely configure this in your web server software.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470