Java 2 Ada

Transparent Web server migration with Apache proxy

By Stephane Carrez 1 comments

When you do a server relocation you get a new server, install it, configure it and make sure your new Web server is ready to go. During this installation, the old server was still running. Now, it is time to make the switch. This article discusses one is

Once your new server is ready, you'll need to update your DNS so that users switch to your new server. The DNS change may take some time to propagate: this is controlled by the DNS TTL (time to live). You could set the TTL to 1 minute (like gmail) but this will increase the traffic to your DNS. Sometimes you don't control the TTL or you must do the IP switch when a previous TTL was very high (for example one day). In those cases, several users will continue to use the old server until the TTL ellapsed.

You can use the Apache proxy module on the old server to redirect the traffic to the new server during the DNS transition.

The configuration extract below is suitable for a Web server with a secure connection (https). On the old server, update your Apache server configuration and use:

 <VirtualHost *:443>
      ProxyRequests Off
      <Proxy *>
            Order allow,deny
            Allow from all
      </Proxy>
      ProxyVia On
      ProxyPreserveHost On
      ProxyPass / https://91.121.nnn.nnn/
      ProxyDomain mydomain.com
 </VirtualHost>

where you'll replace the 91.121.nnn.nnn IP address by your new server IP address, and the mydomain.com by your own domain.

You must also make sure that the Apache mod_proxy modules are installed. For this, run:

 sudo a2enmod proxy proxy_http

Once this is ok, you have to reload the Apache configuration:

 sudo /etc/init.d/apache reload

And of course test your old server and watch that the proxy works correcty!

Add a comment

To add a comment, you must be connected. Login

1 comments

harold@resp.corp.com
harold on 2009-01-25 22:32:46 said:

Sometimes you may have to change the default proxy setting.
For me, it was disabled and I had to explicitly change
a Deny to an Allow. If it happens, edit the file
/etc/apache2/mods-available/proxy.conf