Sunday, 2 January 2011

Testing a website before DNS has propogated

One of my resolutions (I don't have many) is to write some more technical posts. After having a year off real technical work and focusing my direction on house refurbishment and reducing my golf handicap, I am now looking for a suitable new position seriously since around September. I took on the building of a website based on a database I created a while ago (more on that once I have got it officially launched).

The problem that I have was I commissioned a new server using Amazon Web Services (see the previous post) and I could test using the IP address. One of the (minor) issues I have found so far with AWS is that you only get one IP address per instance - you don't have the option of purchasing any more. If you want more IP addresses you need more instances - which means paying more.

To host multiple sites on the one instance means using host headers if you want to host multiple sites.

The other problem that I had was I used the IP address which was assigned to the box and then modified my DNS entries for the domains. Then I setup an Elastic IP address. This is an IP address which is assigned to my account that I can then relate to a server instance. As soon as you setup this IP address the original IP address is lost! This meant I had to change the DNS again!

But I wanted to test the servers as quickly as possible. I can be impatient.

I have used the solution below before. When I worked at GTI we hosted sites in our own network centre. Every site was located on at least two servers and associated with it's (real/internal) IP address (on the private network). When we deployed the site we would setup some temporary (real/internal) IP addresses and check things would work. We could do this over the private network. However, this created issues if any URL's were hardcoded - and also if we were using SSL certificates.

The solution (for testing purposes) is to modify the hosts.txt file on your own computer. This is located in the directory c:\windows\system32\drivers\etc.

hosts.txt file


In this file you can add an entry for new sites that you can then test - either until DNS propagates or on a longer term basis, e.g. unless someone knows the URL (and IP address) and implements the same method on their PC then access to that site from your server will be quite difficult (this is known as "security through obscurity", and therefore should not be relied upon for anything really confidential!).

I also use this to occasionally test sites on my local computer.

Few caveats

  • Remember to remove entries afterwards. Otherwise you will be browsing for a site and getting the wrong one.
  • If you have already browsed to the site, you then need to exit your browser and start a new one in order for it to be picked up. (And with Firefox you might need to stop all browser instances - and check using task manager).

No comments:

Post a Comment