0

I specifically looked up how to do something like this ( Can you set a backup ip for your server in DNS? ) and the answer basically was you can't. If i say specify 2 ip addresses could i somehow use a HTTP response header to ignore it temporary (say 5mins) and go to the other IP address? Or maybe i can play dead however i'm unsure how to play dead using nginx. I then would like to be available after my box notice the other box is down and be some kind of readonly server.

I'm sure something like this has been implemented i am just wondering how i might implement it with 2 boxes. I'm sure it isn't very difficult? How might i redirect traffic from a backup box to my main server without modifying the DNS?

1 Answers1

0

How might i redirect traffic from a backup box to my main server without modifying the DNS?

It's not possible.

I specifically looked up how to do something like this (Can you set a backup ip for your server in DNS?) and the answer basically was you can't

Unfortunately, that answer is correct. The best you can have is a normal HTTP redirect, but the server that is dead must be up in order to issue that redirect.

Essentially, you need to understand how the process works:

  1. Client looks up (via DNS) the IP(s) associated with example.com
  2. It uses the first one, and caches it (DNS servers won't return IPs in the same order every time, they use round robin)
  3. The client attempts to open a connection to that IP, on port 80. If it's dead, it's dead. Client gives up.

You are looking for a method that, after the client gives up, they are 'notified' of a new IP they should try. There's simply no way to do this: the server that is supposedly dead must be up in order to issue the information that it should redirect elsewhere.

The way the DNS methods work is that the bad server is taken out of the DNS pool, so clients don't receive it. They also set the cache time to low, so when the user hits refresh, they are likely given a new IP.

Jay
  • 6,439
  • 24
  • 34