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 updatedWhile Zax's answer is fully accurate, it looks like it wasn't sufficient to help out the OP, and maybe not for others, too.
@
or www
, where the former means "root level" and the latter means "www subdomain".
imsocool.com
, then @
points to imsocool.com
whereas www
points to www.imsocool.com
.A
which is an IPv4 Address or you'll want AAAA
, which is an IPv6 Address. (That's assuming you're trying to point to a website, not an e-mail server or whatever else.)1h
(one hour) default.54.49.66.128
, or whatever your IPv4 (or v6) server address is.imsocool.com
.In your google domain admin dashboard, select the dns configuration of your domain name.
Go to Custom resource records and set a new record with the subdomain you require: for the site webapp.example.com use webapp and select Type A. Leave blank the ttl field and add you public IP from the amazon EC2 instance. Then just browse the site webapp.example.com and it will retrieve the site on your EC2 under the domain name.
If you need to redirect the www.example.com domain then just add a record with www, also selecting the type A and adding your public IP from your EC2 instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With