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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-02-2007, 10:02 AM
|
#1
|
|
LQ Newbie
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5
Rep:
|
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.
|
|
|
|
05-02-2007, 02:32 PM
|
#2
|
|
Member
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 211
Rep:
|
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?
|
|
|
|
05-02-2007, 02:58 PM
|
#3
|
|
LQ Newbie
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5
Original Poster
Rep:
|
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.
|
|
|
|
05-02-2007, 03:24 PM
|
#4
|
|
Member
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 211
Rep:
|
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.
|
|
|
|
05-02-2007, 03:25 PM
|
#5
|
|
Member
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 211
Rep:
|
I just noticed your wording: 'page'.
Do you mean server or literally, 'page'?
|
|
|
|
05-02-2007, 03:37 PM
|
#6
|
|
LQ Newbie
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5
Original Poster
Rep:
|
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.
|
|
|
|
05-02-2007, 03:47 PM
|
#7
|
|
Member
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 211
Rep:
|
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. :|
|
|
|
|
05-03-2007, 08:45 AM
|
#8
|
|
LQ Newbie
Registered: May 2007
Distribution: Red Hat Enterprise 3, 4 and 5
Posts: 5
Original Poster
Rep:
|
figured it out.
I got it working with a shell script and a ping. Thanks for your help.
|
|
|
|
05-03-2007, 08:50 AM
|
#9
|
|
Member
Registered: Oct 2003
Location: USA
Distribution: Ubuntu
Posts: 211
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:29 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|