LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-07-2012, 07:37 AM   #1
superkikim
LQ Newbie
 
Registered: Aug 2006
Posts: 9

Rep: Reputation: 0
Question How to capture web site incoming traffic and redirect to different IP/server


Hi,

I have two Linux servers with Plesk installed (Debian and CentOS) with different IPs.

I want to migrate websites with minimal down time. Therefore I wish to find a way to avoid waiting for DNS propagation.

Scenario is as follow (example IPs):

Website 1 on Server 1: 192.168.0.10 (shared)
Website 2 on Server 1: 192.168.0.10 (shared)

I wish to migrate website 1 to Server 2 with IP 192.168.0.11

As soon as the migration is done, I want all incomming traffic to 192.168.0.10 for website 1 captured and redirected to Server 2 on IP 192.168.0.11.

from my comprehension, I need therefore to capture the combination of traffic and site header. How can I do that, and obviously keep traffic to Website 2 comming to 192.168.0.10 ?
 
Old 11-07-2012, 09:16 AM   #2
lrtward
Member
 
Registered: Feb 2011
Distribution: CentOS, Ubuntu
Posts: 97

Rep: Reputation: 9
iptables

http://serverfault.com/questions/371...ip-no-downtime
 
Old 11-07-2012, 10:39 AM   #3
superkikim
LQ Newbie
 
Registered: Aug 2006
Posts: 9

Original Poster
Rep: Reputation: 0
You just did the mistake I expected...

Quote:
As soon as the migration is done, I want all incomming traffic to 192.168.0.10 for website 1 captured and redirected to Server 2 on IP 192.168.0.11.

from my comprehension, I need therefore to capture the combination of traffic and site header. How can I do that, and obviously keep traffic to Website 2 comming to 192.168.0.10 ?
Your solution will redirect all traffic.... But I have many websites on the same IP and I don't want to redirect all.
 
Old 11-08-2012, 03:53 AM   #4
superkikim
LQ Newbie
 
Registered: Aug 2006
Posts: 9

Original Poster
Rep: Reputation: 0
no other idea ?
 
Old 11-08-2012, 08:38 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,484

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
Set your DNS TTL very low.
Add a DNS entry for your new server as ww2.yourdomain.com
On new server set up apache as SERVER NAME www.yourdomain.com / SERVER ALIAS ww2.yourdomain.com
On old server set up .htaccess redirect to redirect everything to www2.yourdomain.com
Change dns so that www.yourdomain.com points to your NEW server

This means that anything that sees the NEW IP address will just read off the new server, anything that sees the OLD IP address will read a redirect to ww2 from the old server which will force a query to find ww2 from DNS.

Leave this all in place for a few days and then remove the ww2 entries.

As with anything DNS based, your mileage may vary and some users may experience an outage, it's just an unfortunate effect that some DNS servers do not respect standards with regards to TTL.
 
Old 11-08-2012, 11:04 AM   #6
lrtward
Member
 
Registered: Feb 2011
Distribution: CentOS, Ubuntu
Posts: 97

Rep: Reputation: 9
Quote:
Originally Posted by superkikim View Post
You just did the mistake I expected...

Your solution will redirect all traffic.... But I have many websites on the same IP and I don't want to redirect all.
*facepalm*
Of course. I knew that when I started thinking about your problem, but somewhere along the line I got lost and forgot. Sorry about that. Still pondering.

My first thought was using a RewriteRule in httpd.conf to redirect traffic but I didn't find any examples of RewriteRule with IP numbers, only with host names. Ran out of time after getting distracted by the iptables idea... but have you looked into RewriteRule as an option?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect incoming traffic to an other port (ubuntu openvpn server) krisox Linux - Newbie 3 12-06-2010 12:22 AM
Easiest way to redirect external web traffic to VMWare web host on same machine? mattp52 Linux - Networking 4 07-16-2009 02:47 PM
Heavy incoming traffic web servers advice TefoZi Linux - Hardware 1 01-25-2008 03:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration