Search code examples
amazon-ec2dnsodooamazon-route53

Point namesilo domain to EC2 instance with specific port


I do not really know where to start, the other questions pertain to GoDaddy, which seems to have a different enough CNAME configuration area to namesilo that I don't see the parallels.

I bought domain on namesilo and now want to point to EC2 instance BUT

My app on EC2 runs on port 8069, and is also not https (no SSL cert?), so I have to enter http://MY.IP.ADD:8069 to get it to show up.

Anyone know what I can do to get my EC2 app to be retrieved if I enter

www.mydomain.com (without the port number)


AWS Instance and Route 53 'Hosted Zone'

Instance

Hosted Zone


Namesilo

Namesilo CNAME area


Additionally, I would like to not have to worry about https leading to a 'This site can’t provide a secure connection ERR_SSL_PROTOCOL_ERROR'

Any and all help appreciated, thank you!


Solution

  • To be able to enter your domain name into a browser and have it resolve to a public IP, you need to configure an A (or AAAA for IPv6) record with your domain at your registrar (namesilo).

    A/AAAA DNS records do not provide the ability to map to specific ports. So, when you enter http://<yourdomain> into your browser, the browser is resolving <yourdomain> to the IP address configured in the DNS configuration of your registrar for your domain and then it initiates a TCP connection to that IP at port 80 (the default HTTP port). For HTTPS, it is port 443.

    Since your application is not listening on port 80 (or 443 for HTTPS), you need to have some server that does listen on those ports and which translates between the incoming connection from a browser on port 80 or 443 and the connection to your application on port 8069.

    And because you also want SSL with HTTPS, there are a few options here:

    1. install an SSL/HTTPS capable proxy server on your EC2 instance, such as nginx or Apache HTTP server or any other variant, that acts as a reverse proxy towards your own application on port 8069. To obtain an SSL certificate for your domain, you could simply use letsencrypt. There are tutorials on how to install a letsencrypt certificate on an AWS EC2 instance (with Amazon Linux 2).

    2. use an AWS Application Load Balancer (ALB) or a Network Load Balancer (NLB) for the proxy part. The ALB/NLB will listen on 80/443 and forward to your application on its port. So, the ALB/NLB will also do the TLS termination. Here you can issue an SSL certificate via AWS Certificate Manager (ACM) and install it for your domain on the AWS ALB. Next, configure listener rules for your ALB to direct to your EC2 instance on its port.

    So far, the AWS-provided DNS service Route 53 hasn't played a role in the solution. However, you can (if your registrar supports it in the configuration - but I don't think that namesilo actually does for apex records) use DNS delegation:

    Here, if you have a Route 53 public hosted zone with the same name as your custom domain, you will be given a list of typically four name servers provided by AWS that you can then use with an NS record at your registrar's DNS configuration to let incoming DNS queries be delegated to your Route 53 public hosted zone. This allows you to use special AWS Route 53 Alias records pointing at your Application Load Balancer (ALB).

    The solution with Route 53 and its Alias records is especially interesting, since with an ALB you will get a public IP for every subnet your activate the ALB on.