I am using an Amazon EC2 instance to serve a node.js app. I recently purchased a domain name through Google Domains and I want to use that domain name to access my node.js app.
The Google Domains console allows you to forward your domain traffic to another website. I set it to forward traffic to the public IP address of my EC2 instance. I can access my app just fine now, but when I type www.myDomainName.com
into a web browser, the URL bar immediately changes and displays the digits of my EC2 IP address.
I would like the URL bar to display the name of my domain instead.
Note:
I have read a few SO questions related to this and can't figure it out. Some of them are a bit over my head. Many of them say to use an Amazon Elastic IP, but I don't understand why this is necessary if the public IP of my EC2 instance seems to work just fine. If the solution here is to use Amazon Elastic IP, I would really appreciate an explanation as to why that is necessary,
It sounds like you are using Google Domains to redirect to another site once the request has hit the Google servers. This is fine and dandy if you have another domain you are wanting to redirect to.
If you want it to stay under your domain name, but point to another location you need to actually change the DNS entries for your domain.
Go to Google Domain services and change your master(*) (A) record, as well as your WWW (A) record, to point at your public IP address. That way when a DNS request is sent for your domain it will just ask Amazons' servers what to do instead of using a redirect from Google.
Exact Steps:
@
is the root record (or anything not specifically set)[all]www
is the record for when people type www.example.com
A
refers to IPv4 address and AAAA
refers to IPv6 address
A
[IPv4]1hr
(this is an advanced attribute)8.8.8.8
[Google Nameserver]1hr
)
www.example.com
to confirm it has updated