How to change the URL on my Amazon EC2 webserver

7,084

Solution 1

This actually has very little to do with AWS, so you can apply this more generally where you next have hosting.

To solve this, you should setup DNS. At this point, you just add the corresponding entries:

mybusiness.com.  IN A 1.2.3.4
www.mybusiness.com. IN CNAME mybusiness.com

so that (www.)mybusiness.com will work as expected. 1.2.3.4 is the (elastic) IP that Amazon gives you (i.e. the one that ec2-<some numbers>.compute-1.amazonaws.com resolves to).

Solution 2

Your EC2 instance has a public IP address and DNS name. Using your normal domain provider, you can create either an A record pointing to the public IP address, or a CNAME record pointing to the DNS name.

However, if you stop and restart your instance (either intentionally or unintentionally), both your public IP address and DNS name will change. If this happens, you'll have to update your DNS entry for mybusiness.com. This may cause a problem because DNS entries may be cached. You'll have to wait (sometimes 48 hours) for the cache to refresh.

To avoid this problem, there are 2 possible solutions: (a) Use an Elastic IP address. If you do this, you can regain your public IP address and DNS name if your instance is stopped. (b) Use Route 53 to host your mybusiness.com DNS and update your records programmatically when your instance starts. For this to work, you'll need to use a short TTL (time-to-live) on your DNS entries.

Share:
7,084

Related videos on Youtube

Sarah
Author by

Sarah

Updated on September 18, 2022

Comments

  • Sarah
    Sarah over 1 year

    I am at the point in playing around with EC2 that I have launched a webserver. Right now, the website URL looks like http://ec2-<some numbers>.compute-1.amazonaws.com/

    I am evaluating the usefulness of these services for my small business purposes; is there a way I can get my URL to look something more like http://<mybusiness>.com. Ideally, I would like to get it to look cleaner, and furthermore I would rather not have "amazonaws" as part of it. Is this possible?

    I'm a newb to AWS, so apologies if this is an easy question

    • Andrew Smith
      Andrew Smith almost 12 years
      Just use something like freedns and setup some domain with ip number to your machine. You need elastic IP for this.
  • jhayes
    jhayes almost 12 years
    to be clear, the DNS will be controlled by your name registrar (like GoDaddy) and you should be able to control where it points from there. Here is the first link I could find describing how: brangle.com/wordpress/2010/11/…
  • Tom Marthenal
    Tom Marthenal almost 12 years
    Elastic IPs are the appropriate solution here for a webserver that is normally running 24/7.