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.
migrated from stackoverflow.com Apr 2 '10 at 23:06
This question came from our site for professional and enthusiast programmers.
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:
lastly, add an entry on your the /etc/hosts file of your old/current server that has the following syntax:
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.
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.