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.
-
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:
- Old web server is configured to be Reverse Proxy
- DNS Switchover
- New web server serves hits from up-to-date DNS records
- Old web when it gets a hit, forwards the request to the correct DNS, and then outputs the content verbatim.
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)
From Farseeker -
My company just did this with several largish Web sites. The basic procedure we followed was:
- Lower the domain's TTL as much as possible. Do this in advance by at least as much time as the current TTL.
- Set up the Web site on the new server exactly how you want the "final product" to be
- Add an aliased name to the site on the new server, such as www2.domain.com or www-new.domain.com. With Apache, you would use the ServerAlias directive. If the site has any dynamic code at all (PHP, mod_perl, RubyOnRails, etc.), make certain that the site will behave and respond correctly with this new name.
- At cutover time, set up a redirect on the old server pointing to the new server
- Change DNS for www to go to the new IP.
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:
# old server <VirtualHost 1.1.1.1:80> ServerName www.domain.com RewriteEngine on RewriteRule ^(.*)$ http://www-new.domain.com$1 [L] </VirtualHost> # new server <VirtualHost 1.1.1.2:80> ServerName www.domain.com ServerAlias www-new.domain.com </VirtualHost>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:
# old server <VirtualHost 1.1.1.1:80> ServerName www-new.domain.com RewriteEngine on RewriteRule ^(.*)$ http://www.domain.com$1 [R=301,L] </VirtualHost> # new server <VirtualHost 1.1.1.2:80> ServerName www.domain.com # ServerAlias removed, no longer needed </VirtualHost>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.
From James Sneeringer -
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.
From womble -
Ok, based on what @Farseeker recommended, I set up the following config on the old Apache server to forward requests onto the new server:
<VirtualHost *> UseCanonicalName Off ServerAdmin me@domain.com ServerName domain.com DocumentRoot /var/www/ ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://domain.com/ ProxyPassReverse / http://domain.com/ </VirtualHost>To make sure the old server had the correct address, I put an entry in
/etc/hosts:1.2.3.4 domain.comI also had to enable the Apache
mod_proxyandmod_proxy_httpmodules, and reload the config:a2enmod proxy a2enmod proxy_http /etc/init.d/apache force-reloadFrom Tom
0 comments:
Post a Comment