0xBF

0xBF

Nginx Backup

Nginx config:

upstream myapp1 {
    server 127.0.0.1:9001 max_fails=1 fail_timeout=10s;
    server 127.0.0.1:9002 backup;
}

If there is 1 fail in 10 seconds, then send all requests to the backup server (9002) and keep sending requests to 9002 for 10 seconds; After 10 seconds, Nginx will try the primary server (9001) again to see if it is back, if it is back, then switch to send request to 9001, otherwise, keep using 9002.

Reference

 
Share this