Monday, March 31, 2014

Amazon Elastic IP and a Real Domain Name

Got an Elastic IP (EIP) for the Devil Music web server instance and configured it to use our own registered domain name using Route 53 for Domain Name System (DNS) service.

I now had a web server, but it needed to be addressable using a custom domain name.

= tl;dr =
  1. Register a domain with a domain name registrar
  2. Get an Elastic IP (EIP) address associated with your instance
  3. Use Route 53 (or your registrar's DNS tools, if available) to point the domain name at the EIP
  4. Update the server's HOSTNAME in /etc/sysconfig/network.
1. The custom domain names for Devil Music were already acquired by the author, Carly Orosz, quite some time ago -- back when she titled her novel and web comic series. The .net and .org domains were available immediately and were registered through DynDNS *. The .com name was being sat on by a troll, but it was important enough it was bought anyway and was transferred internally with its original registrar, Dynadot, which has also been alright.
* In retrospect, Namecheap might have been a better choice, but oh well.

2. An EIP is necessary so the IP address of your web server instance does not get reset/altered/reassigned each time the instance goes down. To get a new EIP (a) allocated to your AWS account and (b) associated with your instance:
a) AWS console > EC2 > Network & Security > Elastic IPs > Allocate New Address
b) with the new EIP selected > Associate Address > select your instance from the drop-down list

3. DNS service is necessary to inform computers on the network of the IP address of the server given a domain name. Route 53, the AWS DNS service/toolset is cheap (running me ~$1.50/month as of 2014/05/05), well documented, and scalable. To set it up:
a) AWS console > Route 53 > Create Hosted Zone *
* Since the comment can only be up to 256 characters and it cannot be altered once set (which is a bit silly, IMHO), I've just left them empty for the most part.
b) with the new zone selected > Go to Record Sets > Create Record Set > [fill out the form]

- You need a hosted zone for each domain name you register and want served through Route 53.
- You need a Type "A" record set with your EIP as its value for each hosted zone you want directed to your AWS EC2 web server instance.
- I chose to include an "A" Type record for *.devil-music.com aliased to the primary "A" Type record and would recommend others do so. This means you only need the 2 records (and only have to update an IP address once) per hosted zone even if you have www, blog, forum, etc. subdomains all hosted by the same web server.

4. The server's HOSTNAME needs to be set correctly for Apache and SSL to work later, and should be set correctly on principle. Edit the network system configuration file:
sudo /etc/sysconfig/network
Change the line with "HOSTNAME=localhost.localdomain" to the domain name only -- "HOSTNAME=devil-music.com".
* I think this is not 100% correct, but it is working. See What do I need to do in /etc/hosts, in /etc/sysconfig/network, and with the hostname command? on Server Fault.

No comments:

Post a Comment