Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was considering switching to Amazon EC2 to host my website to handle more traffic. It seems like I would have to update DNS records to point to the new server but I was wondering if there was a way to avoid having to wait for the new DNS record to propagate. Putting the code on both hosts would not work for me since the app writes to a database pretty frequently. I thought about just using a meta redirect or php redirect on the old host to redirect to the new host ip but was wondering if there's a better more accepted way of doing this.

share|improve this question

migrated from stackoverflow.com Apr 2 '10 at 23:06

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 9 down vote accepted

here is a trick i use all the time... :) it assumes you control the current server.

put the site/db/whatever on the new server and on your old/current server, enable the proxy, proxy_http and the rewrite modules, then add the following lines on the apache config file for your old/current site:

RewriteEngine on
ProxyPass          /      http://<your-fqdn-here>/
ProxyPassReverse   /      http://<your-fqdn-here>/

lastly, add an entry on your the /etc/hosts file of your old/current server that has the following syntax:

<new-ip-address-of-ec2>   <your-fqdn-here>

that is it. you got a reverse proxy pointing to itself, but resolving its own name to your new server. when the dns propagation rolls out, then the new server will be hit directly. we call this neat little trick PRRP or Pseudo-Recursive-Reverse-Proxy.

For those pesky (by pesky I mean badly designed) web apps that require many holes poked on the firewall, this lets you leave just the reverse proxy server on the dmz and poke only ports 80/443 to the internal network.

share|improve this answer
    
+1 But just to clarify by apps that requires many holes poked on the firewall I think you mean webapps behind the firewall using nonstandard ports or running on their own host. –  Alexandre Jasmin Apr 2 '10 at 23:33
    
@alexandre - yes, webapps! the generalization was force of habit.. been doing [mainly] webapps for a while. :) I updated my post to reflect your correction. –  Peter Carrero Apr 2 '10 at 23:47

Have your old host proxy the http requests to the new host

share|improve this answer

You might also be able to reduce the time you have to wait for the DNS propagation by getting the TTL for the domain name lowered preparatory to the move.

share|improve this answer
    
Wow, I just created this account in the last few minutes and already I've got 31 points... –  SamB Apr 28 '10 at 0:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.