How redirect a domain to Amazon EC2 Machine?

Valter Silva picture Valter Silva · Apr 5, 2011 · Viewed 36.1k times · Source

I'm using EC2 of Amazon to host a website built in JSP :

http://ec2-50-17-144-64.compute-1.amazonaws.com:8080/p2p

And I bought this domain: www.p2pbrasil.com

How can I redirect www.p2pbrasil.com to my website in Amazon EC2 ?

When someone type www.p2pbrasil.com it redirects to http://ec2-50-17-144-64.compute-1.amazonaws.com:8080/p2p ?

Answer

Thomas the Tank Engine picture Thomas the Tank Engine · Apr 5, 2011

You need to do two things

  1. In the Amazon Web Service admin panel, create an elastic IP in the same region as your instance and associate that IP with your that instance (IPs cost nothing while they are associated with an instance, but do cost if not).
  2. Add a A record to the DNS record of your domain mapping the domain to the elastic IP address assigned in (1). Your domain provide should either give you some way to set the A record (the IP address), or it will give you a way to edit the nameservers of your domain.

If they do not allow you to set the A record directly, find a DNS management service like ZoneEdit, register your domain as a zone there and ZoneEdit will give you the nameservers to enter in the admin panel of your domain provider. You can then add the A record for the domain in ZoneEdit.

I only mention ZoneEdit because the basic service is free, you could also use Amazon route 53 or a similar pay-for service, if you preferred.