+ Reply to Thread
Results 1 to 10 of 10

Thread: Script that forwards you to a secondary server if main server is offline

  1. #1
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Script that forwards you to a secondary server if main server is offline

    Is there a script that I can use that would check if fye.x10hosting.com is up and if it is down send connections to a different URL? My members keep telling me my site is down. I'd like to send them to a little page on a different server that tells them the server is down and not to tell me. So all I need is the script that checks the status. Thanks for any help!

  2. #2
    YamiKaitou's Avatar
    YamiKaitou is offline x10 Elder YamiKaitou is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    636

    Re: Script that forwards you to a secondary server if main server is offline

    If HTTP is down, how do you plan on running the script?

  3. #3
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: Script that forwards you to a secondary server if main server is offline

    I'd host it on a different server that has very high uptime.
    (1 minute after I posted you replied. wow)

  4. #4
    YamiKaitou's Avatar
    YamiKaitou is offline x10 Elder YamiKaitou is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    636

    Re: Script that forwards you to a secondary server if main server is offline

    Then it would require you to use a thing like Brandon's server status script that checks to see if the port is up. If it is, it directs them to one place, if not, then it directs them elsewhere

  5. #5
    Torch's Avatar
    Torch is offline x10 Lieutenant Torch is an unknown quantity at this point
    Join Date
    Apr 2006
    Location
    Belgrade, Serbia
    Posts
    317

    Smile Re: Script that forwards you to a secondary server if main server is offline

    Ok, I wrote you up a short script that will check status of one server and if it's up redirect you to it, and if it's not, redirect you to another server. Or, if you un/comment correspoding lines (header and echo), just displays the error messages. The best way to use it would be to give out address of the server (site) you know that'll be up all the time, put it as an index.php there, and than people would be redirected where needed depending of server statuses.
    Ok, here it is...

    PHP Code:
    <?
    error_reporting
    (0); // Disables error reporting
    $URI "google.com"// Your main server address, can be IP too (DON'T PUT http://)
    $URI2 "x10hosting.com"// Your second server address
    $TO 5// Timeout in seconds
    if(fsockopen($URI,80,$TO)){
       
    header("Location: http://$URI"); // Redirects to your server if it works
       //echo "Server is working perfectly!";
    }
    else{
       
    header("Location: http://$URI2"); // Redirects to your second server in case first one doesn't work
       //echo "We are currently having some troubles with the server, please come back later!";
    }
    ?>
    Last edited by Torch; 11-27-2006 at 11:51 AM.

  6. #6
    HabboHaze is offline x10Hosting Member HabboHaze is an unknown quantity at this point
    Join Date
    Sep 2006
    Posts
    31

    Re: Script that forwards you to a secondary server if main server is offline

    So you'd pretty much need another hoster?

  7. #7
    acidburn0520's Avatar
    acidburn0520 is offline x10 Sophmore acidburn0520 is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Florida, USA
    Posts
    117

    Re: Script that forwards you to a secondary server if main server is offline

    For this to work, you'd need an server to act as an intermediary or a gateway of sorts; if the server is online, let the user pass, and if not, display an error. Rather complicated just to give your users a page telling them the server is down.

  8. #8
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: Script that forwards you to a secondary server if main server is offline

    Thanks Torch!!!
    The script works fine if the main server is online, but otherwise firefox gives me a connection reset error. Any idea why?
    Last edited by Christopher; 11-27-2006 at 05:57 PM.

  9. #9
    sunils's Avatar
    sunils is offline x10 Spammer sunils is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Chennai ,India
    Posts
    2,264

    Re: Script that forwards you to a secondary server if main server is offline

    Just Check this

    PHP Code:
    <?php
        error_reporting
    (0);
        
    $ip "first ip address";
        
    $port "port to check";

       
    $url "url to  be redirected to";

        if (! 
    $sock = @fsockopen($ip$port$num$error5))
        {
    ?>
                   <script language='javascript' type='text/javascript'>
                                 location = <?php print $url?> ;
                   </script>
    <?php
        
    }
    ?>
    [LEFT][B]Sunil Sankar
    -------------------------------------------------------------------------

  10. #10
    Sohail's Avatar
    Sohail is offline x10 Spammer Sohail is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    London, UK
    Posts
    3,052

    Re: Script that forwards you to a secondary server if main server is offline

    Where would you place that script as if it was on the first server and that was done then you wouldn't be able to execute the script so i'm guessing it will be placed on the second server and that every time the site is accessed it will go to the second server to run that script right?

+ Reply to Thread

Similar Threads

  1. server offline?
    By NielsJanssen in forum Free Hosting
    Replies: 9
    Last Post: 04-30-2006, 04:35 PM
  2. Server UP time Script
    By dharmil in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 04-03-2006, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers