Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change hostname for AWS ec2 instance

I have an AWS EC2 instance with domain like http://ec2-some-ip-addres.compute-1.amazonaws.com/

Now I want to change this url (add a custom domain which is not registered) to some small alias like testing.webserver.com etc. Can we do that?

I have tried editing /etc/hosts file with

ip-address hostname alias

But not working. What is the best way to change the url without making a DNS entry on no-ip or some other services?

like image 466
Rahul Sagore Avatar asked Oct 08 '15 22:10

Rahul Sagore


1 Answers

To access an Amazon EC2 instance with your own domain name, use a DNS server (eg Amazon Route 53) to point your domain name to the IP address of the EC2 instance.

The steps are:

  • Create an Elastic IP address in the EC2 management console. This is a static IP address that you can then control.
  • Assign the Elastic IP address to your EC2 instance
  • Choose a DNS provider (either your own, or Amazon Route 53)
  • Purchase your domain name (in case you don't already own it), eg example.com
  • Create a subdomain (eg server1.example.com
  • Create an A record in the DNS system to point to the Elastic IP address

You can then access your instance via server1.example.com.

See also: Routing Queries to an Amazon EC2 Instance

like image 109
John Rotenstein Avatar answered Sep 30 '22 07:09

John Rotenstein