LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   help with script to redirect server traffic (https://www.linuxquestions.org/questions/programming-9/help-with-script-to-redirect-server-traffic-550658/)

avenger756 05-02-2007 10:02 AM

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.

deoren 05-02-2007 02:32 PM

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?

avenger756 05-02-2007 02:58 PM

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.

deoren 05-02-2007 03:24 PM

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.

deoren 05-02-2007 03:25 PM

I just noticed your wording: 'page'.

Do you mean server or literally, 'page'?

avenger756 05-02-2007 03:37 PM

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.

deoren 05-02-2007 03:47 PM

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. :|

avenger756 05-03-2007 08:45 AM

figured it out.
 
I got it working with a shell script and a ping. Thanks for your help.

deoren 05-03-2007 08:50 AM

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.


All times are GMT -5. The time now is 03:31 PM.