Hi All, (G'Day) :cool:

(first question in forum)

I would like for my web site to intelligently re-direct to another (host/server) which is my mirror.

I was thinking of maybe using JS or PHP ?? but I have little knowledge other than cutting/pasting/editing to suit.

I use HTML and CSS and hand code all pages to conform to W3c, so far so good. Now that I have started a mirror site, I wish for it to used, and re-directed to, automatically.

:eek:

Any help or tips would be greatly appreciated.

Dani AI

Generated

For : automatic use of a mirror is doable, but it needs something outside the primary host to detect failures and steer traffic. correctly notes that a solution on the primary cannot help if that host is completely unreachable, and is right to point at infrastructure-level approaches. Below are practical options, a small example, and a short checklist to make a mirror actually useful.

A reliable pattern is to put a front-end service on a separate network that performs health checks and fails over to the mirror when the primary fails. That front end can be a managed load balancer or a small reverse proxy you run on another host. The front end should check a dedicated health URL (for example /health) that confirms web + DB + key dependencies are OK, and only then send traffic to the primary.

Example (basic nginx upstream with a backup server):

upstream backend {
    server primary.example.com max_fails=3 fail_timeout=10s;
    server mirror.example.com backup;
}

server {
    listen 80;
    location / {
        proxy_pass http://backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Operational points to avoid common pitfalls: keep files and databases in sync (rsync or replication), store sessions centrally or avoid sticky sessions, make your health endpoint validate real dependencies, test failover regularly, and remember SSL/cookie/domain issues when switching origins. If you choose DNS-based failover, use a provider with multi-site health checks and low TTLs, but expect some clients to cache old answers.

Recommended Answers

All 4 Replies

Redirection can be accomplished either client or server side, but the real question is, why? When?

Redirection can be accomplished either client or server side, but the real question is, why? When?

Sorry I didn't really make it clear...

---
It is for times of Primary Server down time, or the server/hosting having issues....

I would like for 'something' to see that the primary is OFF-AIR and then to load the mirror...


or am I dreaming? :p

If the server is completely down, there's nothing you can do. If the server is under load, it can redirect.

I suggest you post in the 'Site Management | Web Hosting' forum.

The only way to achieve it when the server is down is to do some fancy dns and hope the updates propogate in time.

If you have a mirror site then dont leave it for times when the other is down. Make use of it and load balance, that way you should have a better chance if the primary goes down.

To be honest if it is that important to you (which most sites are) and you are worried about availability that you have gone to another mirror i would be inclined to look at your current primary hoster and see why they cant guarantee the uptime. Maybe look to move. Though you may be your hoster in which case i understand the dilemma and go back to my earlier point that you should load balance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.