skip to Main Content

I have a complicated scenario where I need to redirect domain requests to another domain for some requests but stay in the original domain for others.

For example, if I had www.abc.com:

I want to route www.abc.com to www.abc.app. Or if the user types in www.abc.com/hello then it will route to www.abc.app/hello. This is currently done via load balancer and creating an "A" record in Route53 connected to the load balancer

BUT I want to reserve a specific subdomain. Let’s say if the user types in www.abc.com/game, then I want it to display a NodeJS application that’s hosted in a separate EC2 server. The domain will not change and it will remain as www.abc.com/game.

Is this at all possible to do if the "A" record is already being taken by the load balancer?

2

Answers


  1. No. This is not possible to do with DNS.

    DNS servers simply convert the domain name (www.abc.com) to an IP address. The ‘path’ portion (/game) is not sent to the DNS servers, so they cannot use that to change the DNS resolution process.

    You will either need to:

    • Use different sub-domains (eg game.abc.com), or
    • Send all traffic to one location and then have the receiving service figure out how to process the requests, or
    • Use URL Rewriting With Lambda@Edge | smarx.com, which can ‘intercept’ the request and rewrite it, which could send the request to a different location or tell the user’s web browser to send the request to a different location
    Login or Signup to reply.
  2. You could use an application load balancer and path based routing.
    https://repost.aws/knowledge-center/elb-achieve-path-based-routing-alb

    If your node app were amplify, you could use path based routing to /games.
    https://docs.amplify.aws/javascript/build-a-backend/restapi/configure-rest-api/

    You could use api gateway. Check out the Routing API requests, section.
    https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html

    You could use CloudFront origins, too.
    https://hitaha.medium.com/path-based-routing-on-aws-cloudfront-host-multiple-amplify-and-s3-apps-under-one-domain-3d47dda9e2c3

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search