Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have two self hosted public web servers. One is my live site, and the other is a minified site that I also use to reroute the traffic to it when I have my live site under maintenance.

My firewall is a cloud hosted firewall. The way I do things now is when I want to take the live site down and re-route to the backup site, I send a request to the cloud hosted firewall people and they do the switch for me. The whole process take about 10-15 minutes. And when I want to go back live. I send in another request and wait another 10-15 minutes.

The problem is that, just switching back and forth is a good 30 minutes! I want to be able to do the switch almost instantly!

How can I go about having it so that. If the main web server is down, All the traffic goes to the backup webserver and vice-versa? Or if there is a way that I can switch between both servers on-demand?

share|improve this question

migrated from superuser.com Nov 22 '13 at 14:18

This question came from our site for computer enthusiasts and power users.

    
If your 'live site' goes down, do you mean the actual server goes down? Or just the content? If just the content, you can set up a Redirect Page on the main page of your Live Site to your mini site. If the actual server goes down, you can temporarily change your mini site IP address to use the live site IP address. IP switching may still includes some down time, but may be faster (testing required) than your hosted firewall . –  Darius Nov 21 '13 at 23:39
    
I would probably try to implement the IP address one. You could even just swap their two IPs briefly. That way the cloud firewall and DNS are always pointing at the working website without changing them (and the associated delays). It would mean that to access the "Production" Webserver you would connect to the "Development" address while you make your changes. Then run a counter script that puts them back to normal mode. There might be a slight delay while any networks update each other where the new addresses are, but it's pretty damn close to instantaneous switching. –  PsychoData Nov 21 '13 at 23:45
    
I might resort to the IP change solution. Will probably just write a script that swaps the IPs between the two PCs. Before I get all excited and start working on this. Is there a way to "remotely" but in the same network, change an IP address? For example. Can I be sitting on my PC, execute the script and that will swap my two web server IP addresses? –  unknownsolo Nov 22 '13 at 0:07
    
What OS are the servers running ? I know for sure that it's possible on Linux with a script. Not sure about Windows since it's been a long while since I've done any scripting on Windows Servers. Are the Webservers VMs or physical boxes ? –  Lawrence Nov 22 '13 at 0:19
    
They are both Windows Server 2008 VMs –  unknownsolo Nov 22 '13 at 0:20

2 Answers 2

up vote 0 down vote accepted

Instead of manually switching back and forth between your "live" site and your backup site, you could point your domain at a CDN like CloudFlare.

On the other hand, if you want to use the IP-swapping technique discussed in the comments to your question and both web servers have static IPs, you can use netsh to export each network configuration. Put the two configurations on each server (or on a network share accessible to both servers) then invoke a script that uses netsh to import either the original or alternate network configuration on-demand. You can use PowerShell or PSExec to remotely invoke the script on each server.

share|improve this answer
    
that kind of defeats the fact that he went to all this trouble self hosting... –  PsychoData Nov 21 '13 at 23:46
    
@PsychoData there's no reason he can't continue to host the "live" site himself. –  rob Nov 22 '13 at 0:07
    
I need to look into this! Will this be a free solution? hoping to achieve this for no extra cost to the company! Will I just be able to let cloudflare know that I have live.website.com and test.website.com and swap between the two as needed when a customer goes to website.com? –  unknownsolo Nov 22 '13 at 0:12
    
@unknownsolo It's a freemium service--basic features are free, and you pay if you need the more advanced features. I'm not sure about the swapping; the idea is that CloudFlare would take the place of the backup website and optionally your hosted firewall. It would automatically serve content from its cache for static content and when the live site goes down. –  rob Nov 22 '13 at 0:22

Use Apache's reverse proxy feature on a 3rd site or virtual host (i.e. example.com). You can configure it to proxy requests to your live site (i.e. live.example.com) or test site (i.e. test.example.com) by editing a line in a configuration file and telling Apache to reload its configuration. This can easily be scripted (at least under Linux). Search for "apache reverse proxy" to find tutorials and examples.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.