5

As you know amazon EC2 instances get an address like:

ec2-72-44-40-153.z-2.compute-1.amazonaws.com

If I have the domain example.com, is there any way that I can make bob.example.com or preferably example.com/bob redirect to the IP of

ec2-72-44-40-153.z-2.compute-1.amazonaws.com

??

Thanks!!

2
  • Robert, it would be nice if you waited a bit longer than 30 minutes after asking to select an answer. The first answer may not be the best one, and an open question can be an incentive to others who may otherwise ignore your question. Jun 10, 2009 at 21:22
  • ec2-72-44-40-153.z-2.compute-1.amazonaws.com does not look like an IP address at all.
    – bortzmeyer
    Jun 11, 2009 at 6:39

2 Answers 2

5

If you just want to redirect a domain, you can create a CNAME record in DNS:

bob.example.com IN CNAME ec2-72-44-40-153.z-2.compute-1.amazonaws.com

Which will redirect everyone trying to connect to bob.example.com to your EC3 site.

If you want example.com/bob to redirect, you will need to configure some URL rewrite rules on the webserver running on example.com.

2
  • Will the domain redirection also work if the domain is not accessed from a web browser>
    – robert
    Jun 10, 2009 at 20:36
  • Yes - domain redirection will work with anything that attempts to resolve using DNS. URL redirection will (I believe) only work with HTTP requests. Jun 10, 2009 at 20:41
5

Amazon has provided a solution that is perfect for your requirements, and more flexible than a CNAME record. You can request a so-called Elastic IP address from EC2.

This IP address is static, so you can create an A record in your DNS that points to it, but it points to an EC2 instance of your choosing. A regular A record like the following would be fine:

bob.example.com    A    123.123.123.123

If your server goes down and you boot another instance (which gets a different hostname), simply reallocate the Elastic IP to the new instance. In a minute or two, the new instance is available behind the IP. This means there will be far less delay than you would experience from a DNS change.

Elastic IPs are free, as long as they are in use. You get charged a small hourly amount when you're not using the IP. This is done to discourage bad usage of limited resources.

You can request and assign the Elastic IP's via the API tools, or a GUI such as ElasticFox. Reading Amazon's howto will make things clearer.

You must log in to answer this question.