I currently have a domain name registered for a Linux/Apache server that I am going to replace with another on a new IP address.
Migrating the data will be relatively quick and a 5 minute disruption during that process is acceptable.
The DNS record has a TTL from 6-12 hours apparently, which I can't speed up.
What are the likely consequences of this change? Presumably users who are still looking at the old address will continue to hit the old server, while users who's dns cache has expired or is empty will see the new domain.
Is it possible to do some kind of redirect from the old server (with Apache or iptables) to the new IP? The old server can continue to run as long as necessary.
My company just did this with several largish Web sites. The basic procedure we followed was:
For Apache, you should probably use mod_rewrite for the redirect so you can preserve the URIs requested by the client. A simple implementation would be:
This will do a 302 temporary redirect for www.domain.com/anything to www-new.domain.com/anything. You want it to be temporary because you probably want search engines to only index www.domain.com, not www-new.domain.com.
Once the DNS change for www.domain.com has propagated to your satisfaction, you can either dump www-new altogether, or gently ease anyone using it back over to www with another redirect. It's almost the same process as above; set up the old server to handle www-new, change DNS for www-new to point to the old server, and set up a redirect on the old server sending www-new traffic to www:
This time you want to do a permanent 301 redirect, again to clue in search engine crawlers that www.domain.com is the site you want them to index.
You can use a Reverse Proxy on the old web server. It might be a bit of work to set up, but just as long as ITS DNS is up to date you will be OK.
What will happen is:
If you're running Apache, look into mod_proxy. If you're running IIS, look into ISAPI Rewrite to get this sort of functionality.
(note that the DNS on the old web server needs to be up to date if you want to proxy using the domain name. Otherwise, proxy it directly to the IP address and make sure that the host is listening on the IP without a hostname)
Ok, based on what @Farseeker recommended, I set up the following config on the old Apache server to forward requests onto the new server:
To make sure the old server had the correct address, I put an entry in
/etc/hosts
:I also had to enable the Apache
mod_proxy
andmod_proxy_http
modules, and reload the config:It's an old thread but maybe it will help someone:
In addition to answers of Mark Henderson (mod_proxy) OR James Sneeringer (302,301 redirect to new subdomains), one more thing could be added regarding database sync when moving big applications.
If your web project uses a database (ex. MySQL), before switching the DNS, make sure the applications (ex. PHP) from both servers are connecting to the same database. So that the read and writes are going to the same place and you don't have to deal with different DB sync tools afterward.
This would (most probably) affect the loading time on one server but for the switch period this can be accepted.
In case the DB server is not accessible from outside, you could setup also the mysql_proxy on the web server which has access to it and is accessible from external IPs.
I use iptables for this when I need to do this; a quick bit of DNAT/SNAT and all your traffic magically reappears where it should be. If you have a real need to maintain source IP addresses a reverse proxy can help, by setting appropriate headers, but that requires a lot of faffing around at both ends to make sure it all matches up, so I don't normally worry about it for something like a migration as it's transient, and lowering TTLs handles most of it.