[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Moving web server to new IP



On Wed, Jul 26, 2006 at 09:05:03PM +1200, Simon wrote:
> I know this is strictly not a debian question, but i will be using
> debian todo it!
> 
> I need to move our web server to a new IP range. This is hosting
> around 300 websites, about 250 on 2-3 IPS (standard name based virtual
> hosts) and the rest on their own IPs (SSL hosts). All running on
> apache/php/mysql.
> 
> Im wondering how i can achieve this over a period of a week rather
> than all in one go.

set up a host in your own domain called 'vhost.your.domain.com' or
whatever. make sure that your web server is configured to use both
the new and the old IP address. gradually change the DNS for the
virtual host domains so that www.vhostdomain.com is a CNAME for
vhost.your.domain.com rather than an A record.

dual hosting of the web server gives you time to move them gradually.
pointing the www. records at a CNAME will make it easier to move them
all again in future if you ever need to.

if you don't want to use a CNAME (and there are pros and cons - e.g.
dont do it if you want an MX record pointing at the same IP), but still
don't want to manually edit 250 zone files, you can use perl to change
them all in one go. something like:

perl -p -i.bak 's/\b\d{10}\b/2006072701/; s/OLD_IP_OF_WEBSERVER/NEW_IP_OF_WEBSERVER/g;' *

NOTE: the "*" on the end indicates all files in the current directory.
use standard shell wildcards to refine the file selection if you need
to.

if you're paranoid (as i am), copy all the zone files to subdirectory
under /tmp and run it in there first as a test to confirm that it will
do what you want. when you're happy with the result, run it in the
directory where you keep your primary zone files.

note that the first search and replace looks for any sequence of 10 digits and
replaces them with today's date.  this assumes two things: 1. that you use the
standard YYYYMMDDnn format for the zone's serial number, and 2. that you don't
have anything else that looks like a serial number in the zone file.


btw, you can use perl to automatically change all the A records to point
at the CNAME too...you just need a slightly more complicated search
regexp:

perl -p -i.bak 's/\b\d{10}\b/2006072701/; s/IN\s*A\s*OLD_IP_OF_WEBSERVER/IN	CNAME vhost.your.domain.com./;' *


> My thoughts are to set up some sort of proxy to proxy the requests
> from one IP range to another. But, this would result in wierd hit
> stats (coming from the proxy IP rather than the client IP - i think).

are the two IP addresses in the same network segments or at the same
physical real-world location?

if so, then just make sure both IP addresses are routed to your web server.

if not, then proxying will be needed. you could do it with DNAT, but
only if the two different IP networks are routed to the same actual
location (i.e. at the same ISP or your own network blocks) - in which
case, you're better off either routing both IPs to the same host or (as
below) putting a second NIC in the web server. much simpler and less
hassle than DNAT.

(as for stats, i vaguely recall seeing an apache module which looked
at the "Via:" headers added by proxies to the request and logged that
rather than the actual TCP source address. can't remember what it's
called. it's not something that's very important, though, esp. if it's
only going to be for a week or so).

alternatively, put a second network card in the web server and connect
it to both networks (if physically possible).



craig

-- 
craig sanders <cas@taz.net.au>           (part time cyborg)



Reply to: