0

I've started to get into AWS today and created a simple EC2 Instance with a Node.js app listening on port 3001.

I can access it through my public DNS at ec2-12-34-123-123.eu-central.amazonaws.com:3001 and get a Hello World output.

Not I'm trying to set up a custom domain to this instance.

I've done the following steps:

  1. Created a domain with Route 53
  2. Created an Elastic IP and assigned it to my EC2 Instance
  3. Created a Hosted Zone and an A record for the Elastic IP

But still I can't access my server via mydomain.com:3001

Did I do anything wrong?

And how can I setup multiple subdomains forwarding to a specific port? For example:

api.mydomain.com
mydomain.com
jenkins.mydomain.com

and so on, when everything is listening on another port?

Creating a record for my IP:port I get wrong value, because the ip:port syntax is not valid.

Edit:

Just did everything again.

  1. created EC2 instance, launched node app on port 80
  2. created elastic ip
  3. created hosted zone for domain
  4. registered ns on registrar for my domain
  5. created A record for www.mydomain.xyz + alias mydomain.xyz

When I try to go to www.mydomain.xyz I only get the Gandi page with my data.

Does anyone know what I did wrong?

eScoo
  • 151
  • 3
  • 14

1 Answers1

1
  1. How long has it been since you registered the domain and created the CNAME or A record to point to your server? It can take about 24 hours for this to propagate and start resolving to your server.

  2. Subdomains are DNS entries that point to a server. You can't forward them to a specific port, they basically point to all ports on the server. If you don't want to include a port number in the URL then you need to have something listening on the default port (port 80 for HTTP, or port 443 for HTTPS). If you need multiple web servers running on different ports on a single server, then you would need to add a reverse proxy like Nginx to that server to map the different domain names to the different ports.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • You actually can point domain names at specific ports via `SRV` records. More on the subject can be found [here](http://stackoverflow.com/questions/19015138/how-to-redirect-dns-to-different-ports). – Itay Grudev Apr 22 '16 at 23:55
  • @ItayGrudev that's a bit misleading. SRV only works for certain protocols, and there are plenty of protocols, like HTTP, that don't support SRV. – Mark B Apr 23 '16 at 00:07