How can I temporarily override a domain name resolution without using the hosts file?

1

I have 2 versions of the same website located on different IPs -- one is production, and one is staging.

The production server: is managed completely by Site5. DNS is done so that foo.com resolves to Site5's servers and they take care of the rest.

The staging server: is an EC2 instance and Apache is set up with a name-based virtual host, foo.com.

As a developer, when I need to work on the staging version, I change my hosts file so that:

foo.com    1.2.3.4    # the elastic IP associated with my EC2 instance

so when I am in my browser and I visit foo.com, I see the staging version. I comment out the line when I want to see the production version.

This is all fine for me, but others on the team are not as tech savvy and are scared of the Terminal.

Is there a better way of doing this, preferably a method that doesn't require diving into the Terminal or other "scary stuff"?

Perhaps a proxy server they can choose to use/not use when they want to see/not see the staging version?

Samuel

Posted 2012-04-26T14:40:05.653

Reputation: 323

Answers

1

Access it using the ipaddress or use a domain name that is unique. All links within the website should be relative otherwise the Site would also break if hosted on another domain.

Brian

Posted 2012-04-26T14:40:05.653

Reputation: 8 439

2Unfortunately, the website is wordpress and links aren't relative. There are ways to rename the domain name from within wordpress, but it's a big pain and adds to the complexity when migrating between staging and production. – Samuel – 2012-04-26T14:56:02.840

1

Editing the hosts file (with notepad.exe) is really the easiest and quickest way in Windows to override hostname resolution. Command line alternatives will be more long-winded and complex.

If you want it to stay temporary just keep the hosts file open and just hit save once you've made changes.

BloodyIron

Posted 2012-04-26T14:40:05.653

Reputation: 1 981

1Yes, I do agree it is easy to change hosts. But I'm looking for a better solution that doesn't change the file, because changing hosts requires admin privileges and is in general, a pain. – Samuel – 2012-04-26T15:00:31.507

If you don't have local admin privileges you are unlikely to be able to override local resolution on the system. You will need to "man-in-the-middle" between your computer and what I assume is your corporate network with a router to override resolution per domain. Default router firmware will not provide specific DNS entries, so you will need to look at routing suites such as DD-WRT or PFSense to give you the level of control you need. However your corporate network will likely pick up on the rogue router. – BloodyIron – 2012-04-26T15:15:24.237

Right, I was thinking along the same lines - hence, I'm wondering if a proxy server acting as "man-in-the-middle" would suffice instead of a rogue router? Or a reverse proxy of some sort? – Samuel – 2012-04-26T15:29:04.967

If you don't have local admin you are unlikely to have the ability to change your local network settings, or install applications such as a proxy or VPN, due to the level of changes they would need to make to the environment. However if you man-in-the-middle with a router, that's something the operating system can't lock you out of unless you have static IP settings, which you can still work around. – BloodyIron – 2012-04-26T16:42:59.540

0

One way I've solved this problem in the past is by using http://xip.io.

It's possible to add an Apache SeverAlias directive on your server like:

ServerName foo.com
ServerAlias 1.2.3.4.xip.io 

and still have your WordPress site serve it (depending on how fancy you're getting with your WP setup).

The disadvantage, of course, is this is still a bit confusing. At least it requires less technical savvy than editing the hosts file. Hope this helps!

Alex W

Posted 2012-04-26T14:40:05.653

Reputation: 101