LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-02-2007, 10:02 AM   #1
avenger756
LQ Newbie
 
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5

Rep: Reputation: 0
help with script to redirect server traffic


I am trying to write a script to check and see if a server is up and based upon a set amount of time (ie 5 minutes or 10 minutes) it will redirect web traffic to an alternate site. Can this be done with a shell script or do I need to use a programming language? Any help would be appreciated.
 
Old 05-02-2007, 02:32 PM   #2
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Rep: Reputation: 30
Are you trying to develop a mirroring script? Perhaps a proxy for incoming connections from the Internet?

There is probably a solution already out there for what you're trying to accomplish. Could you be more specific?
 
Old 05-02-2007, 02:58 PM   #3
avenger756
LQ Newbie
 
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5

Original Poster
Rep: Reputation: 0
Basically at my job our main webpage is hosted outside the building. We use a javascript to from a local linux server to redirect all of our desktops to that page. We have had trouble with the page going down for a few hours and would like to redirect all clients that use this as a homepage to a backup page in case it goes down. The script or program I am trying to figure out how to write will ping the site if its up do nothing. if it is down for say 5 minutes it would change javascript redirection to our backup page. And then when it detected the page back up it would change it back.

Hope this clarifies what I am trying to do.
 
Old 05-02-2007, 03:24 PM   #4
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Rep: Reputation: 30
It sounds to me like a PHP, Perl, Python, ... script could be used here.

What I'm not understanding is where the JavaScript is being used at. Are you using an Automatic proxy configuration script?

After thinking about it a bit I'd probably suggest a monitoring service be setup to change the internal DNS entry for that external website when it goes down.

The new DNS entry would point to another site.

I've done this manually in the past when a hobby server had to be shutdown for repairs or whatnot.
If I come across anything more useful I'll post back.

Hopefully someone with more knowledge will post soon.
 
Old 05-02-2007, 03:25 PM   #5
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Rep: Reputation: 30
I just noticed your wording: 'page'.

Do you mean server or literally, 'page'?
 
Old 05-02-2007, 03:37 PM   #6
avenger756
LQ Newbie
 
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5

Original Poster
Rep: Reputation: 0
i meant website it is our main website. the only problem with changing the dns entry is our dns server are windows based.

The javascript is our another webserver and it just redirects traffic to the main webpage. I figured it would be the best place to redirect computers to our backup page.
 
Old 05-02-2007, 03:47 PM   #7
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Rep: Reputation: 30
Oh okay, I think I understand now.

They're sent to the backup page by default and then redirected to the main site by way of JavaScript within the backup page.

Is the data on the main site mostly static? If so you could mirror it on the backup system and not redirect them outside to the main site.

Otherwise using a server side script sounds like the way to go. I'm not familiar enough with any of the scripting languages to give any code examples though. :|
 
Old 05-03-2007, 08:45 AM   #8
avenger756
LQ Newbie
 
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5

Original Poster
Rep: Reputation: 0
figured it out.

I got it working with a shell script and a ping. Thanks for your help.
 
Old 05-03-2007, 08:50 AM   #9
deoren
Member
 
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 214

Rep: Reputation: 30
Sorry I wasn't more help. If the shell script doesn't contain proprietary info, perhaps post it for others to use? Maybe change IP addresses if need be.
 
  


Reply

Tags
failover


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 All Traffic Through SSH wwnexc Linux - Networking 2 03-14-2007 05:37 AM
how to redirect traffic from one server to another orko Linux - Networking 1 08-12-2006 08:48 AM
redirect traffic tim24 Linux - Networking 5 04-06-2006 10:45 AM
Traffic redirect friki Linux - Software 2 11-04-2004 04:59 PM
Redirect traffic to internal IP? xmutex Linux - Networking 1 08-13-2001 10:29 AM


All times are GMT -5. The time now is 02:04 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration