Using mod_proxy to avoid DNS propagation during site migration

There are a number of ways to migrate a site to a new server, whilst avoiding downtime or data concurrency issues. For a highly dynamic site, generally I would edit the old and new site connection strings to both use the same database during switchover.  mod_proxy is a useful method perhaps if a new version of the site is going live on the new server. Using mod_proxy, the new server can be configured to send site requests to the old server. This means that the DNS can be updated without anyone noticing. Once DNS has propagated, the new site can then be put live on the new server instantly, at any time by removing the proxy rules and resuming the standard vhost configuration.

Very simple to set up, make sure that mod_proxy is enabled by un-commenting the following in your httpd.conf:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Then edit /etc/hosts on the new server to tell it to access the website at the old server:
85.233.111.222 www.mydomain.com

Then add the following two lines to your vhost configuration and restart apache.:
ProxyPass / http://www.mydomain.com/
ProxyPassReverse / http://www.mydomain.com/

You can leave a response, or trackback from your own site.

Leave a Reply